1

How do I get the mouse x/y position relative to an element - a canvas element in this case - using Script#, preferrably without using onmousemove events?

I cannot seem to find anything in there with this data and the way I would usually do it with Javascript - window.event.clientx - doesnt seem to have been replicated.

4

1 に答える 1

1

You typically don't want to refer to Window.Event ... you typically use the event object passed in into your event handler as an argument.

While the Event object has been mapped (https://github.com/nikhilk/scriptsharp/blob/master/src/Libraries/Web/Html/ElementEvent.cs) but right now ClientX and ClientY aren't ... presumably because most people simply are using jQuery's event wrapper/abstraction. That said, it would be good to complete the event object with missing properties like these. If you'd like you can fork and update, and submit a pull request, or submit an issue, and soon enough it will be fixed.

An ugly workaround (if you really can't fork/build etc.) would be to use Type.GetField and do a late-bound access for "clientX".

于 2012-08-01T06:05:59.007 に答える