Skip to content

Commit

Permalink
Merge pull request #3970 from blink1073/add-figure-event-webagg
Browse files Browse the repository at this point in the history
ENH : Add Figure Enter/Leave Events to Webagg
  • Loading branch information
tacaswell committed Jan 6, 2015
2 parents c2c2b4d + 678c807 commit cdb6771
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/matplotlib/backends/backend_webagg_core.py
Expand Up @@ -191,7 +191,8 @@ def handle_event(self, event):
pass
elif e_type == 'draw':
self.draw()
elif e_type in ('button_press', 'button_release', 'motion_notify'):
elif e_type in ('button_press', 'button_release', 'motion_notify',
'figure_enter', 'figure_leave'):
x = event['x']
y = event['y']
y = self.get_renderer().height - y
Expand All @@ -213,6 +214,10 @@ def handle_event(self, event):
self.button_release_event(x, y, button)
elif e_type == 'motion_notify':
self.motion_notify_event(x, y)
elif e_type == 'figure_enter':
self.enter_notify_event(xy=(x, y))
elif e_type == 'figure_leave':
self.leave_notify_event()
elif e_type in ('key_press', 'key_release'):
key = event['key']

Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/backends/web_backend/mpl.js
Expand Up @@ -125,6 +125,9 @@ mpl.figure.prototype._init_canvas = function() {
// Throttle sequential mouse events to 1 every 20ms.
rubberband.mousemove('motion_notify', mouse_event_fn);

rubberband.mouseenter('figure_enter', mouse_event_fn);
rubberband.mouseleave('figure_leave', mouse_event_fn);

canvas_div.append(canvas);
canvas_div.append(rubberband);

Expand Down

0 comments on commit cdb6771

Please sign in to comment.