Extension to MPL to support the binding of artists to key/mouse events.
Register a callback for an artist to a particular trigger event.
The action callback is associated with particular artists. Different artists will have different kwargs. See documentation on the contains() method for each artist. One common properties are ind for the index of the item under the cursor, which is returned by Line2D and by collections.
name is the event name which was triggered artist is the object which triggered the event x,y are the screen coordinates of the mouse xdata,ydata are the graph coordinates of the mouse button is the mouse button being pressed/released key is the key being pressed/released shift,control,alt,meta are flags which are true if the
corresponding key is pressed at the time of the event.
When receiving an event, first check the modifier state to be sure it applies. E.g., the callback for ‘press’ might be:
if event.button == 1 and event.shift: process Shift-click
Todo : | Only receive events with the correct modifiers (e.g., S-click, |
---|---|
Todo : | or *-click for any modifiers). |
Todo : | Only receive button events for the correct button (e.g., click1 |
Todo : | release3, or dclick* for any button) |
Todo : | Support virtual artist, so that and artist can be flagged as |
Todo : | having a tag list and receive the correct events |
Todo : | Support virtual events for binding to button-3 vs shift button-1 |
Todo : | without changing callback code |
Todo : | Attach multiple callbacks to the same event? |
Todo : | Clean up interaction with toolbar modes |
Todo : | push/pushclear/pop context so that binding changes for the duration |
Todo : | e.g., to support ? context sensitive help |
Find the artist who will receive the event. Only search registered artists. All others are invisible to the mouse.
Process button click
Process button double click
Process key click
Process key release
Track enter/leave/motion through registered artists; all other artists are invisible.
Process release release
Process scroll event
Remove connections for artists h1, h2, ...
Use clearall() to reset all connections.
Clear connections to all artists.
Use clear(h1,h2,...) to reset specific artists.
In case we need to disconnect from the canvas...
Trigger a particular event for the artist. Fallback to axes, to figure, and to ‘all’ if the event is not processed.