Closed mwcraig closed 6 years ago
Ping @maartenbreddels and @ejeschke in case you are interested in this feature...
This looks great. What if I want the mouse position in multiple coordinate systems?
This looks great. What if I want the mouse position in multiple coordinate systems?
I'm inclined to say multiple listeners...but am open to suggestions for how to handle that case.
I'm inclined to say multiple listeners
That makes sense.
I think I've addressed all of the comments. I'll add some documentation a little later, once #20 is merged (there are substantial changes to the doc notebook in there).
Thanks for the feedback, merging.
This PR adds the ability to pass the mouse position vi a trait instead a custom event message.
Assuming
e
is anEvent
, settinge.xy_trait_coords = 'page'
(or any of the other coordinates returned in a mouse event), means thate.xy
will be updated with the position of the mouse. Any other event can also be attached and generate event messages like usual.Setting
e.xy_trait_coords = None
turns off thexy
trait.A question that should be answered before merging:
array
coordinates but that is not defined for the view to which theEvent
widget is attached? This can't be checked whene.xy_trait_coords
is set, becausee.source
may not have been set yet, and even if the source has been set, there may not be a view, which is what generates the array coordinates. Right now there is an error displayed in the javascript console, but most users won't ever see it.Minimum working example:
In a subsequent cell
e.xy
will print the mouse position.@pbugnion -- if you can review this one it would be helpful. I'll add to the documentation before merging, just holding off on that in case you suggest any changes to the interface.
Closes #8