From 5667d96137d41624528dd70fc1266923d3babf43 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 10 Sep 2020 02:51:28 -0400 Subject: [PATCH 1/2] Remove outdated note about middle click in nbAgg backend. This was fixed by #18172. --- lib/matplotlib/backend_bases.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/matplotlib/backend_bases.py b/lib/matplotlib/backend_bases.py index 816db303ff65..62b0a3c47f8f 100644 --- a/lib/matplotlib/backend_bases.py +++ b/lib/matplotlib/backend_bases.py @@ -1411,9 +1411,6 @@ class MouseEvent(LocationEvent): ---------- button : None or `MouseButton` or {'up', 'down'} The button pressed. 'up' and 'down' are used for scroll events. - Note that in the nbagg backend, both the middle and right clicks - return RIGHT since right clicking will bring up the context menu in - some browsers. Note that LEFT and RIGHT actually refer to the "primary" and "secondary" buttons, i.e. if the user inverts their left and right buttons ("left-handed setting") then the LEFT button will be the one From 106cb6df3e18660cbab57f71a800ae12b6f9bdd5 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 10 Sep 2020 03:13:15 -0400 Subject: [PATCH 2/2] Handle double-click in webagg/nbagg. --- lib/matplotlib/backends/backend_webagg_core.py | 9 ++++++--- lib/matplotlib/backends/web_backend/js/mpl.js | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backends/backend_webagg_core.py b/lib/matplotlib/backends/backend_webagg_core.py index 796026184201..2540ffe5e6f9 100644 --- a/lib/matplotlib/backends/backend_webagg_core.py +++ b/lib/matplotlib/backends/backend_webagg_core.py @@ -264,6 +264,9 @@ def _handle_mouse(self, event): guiEvent = event.get('guiEvent', None) if e_type == 'button_press': self.button_press_event(x, y, button, guiEvent=guiEvent) + elif e_type == 'dblclick': + self.button_press_event(x, y, button, dblclick=True, + guiEvent=guiEvent) elif e_type == 'button_release': self.button_release_event(x, y, button, guiEvent=guiEvent) elif e_type == 'motion_notify': @@ -274,9 +277,9 @@ def _handle_mouse(self, event): self.leave_notify_event() elif e_type == 'scroll': self.scroll_event(x, y, event['step'], guiEvent=guiEvent) - handle_button_press = handle_button_release = handle_motion_notify = \ - handle_figure_enter = handle_figure_leave = handle_scroll = \ - _handle_mouse + handle_button_press = handle_button_release = handle_dblclick = \ + handle_figure_enter = handle_figure_leave = handle_motion_notify = \ + handle_scroll = _handle_mouse def _handle_key(self, event): key = _handle_key(event['key']) diff --git a/lib/matplotlib/backends/web_backend/js/mpl.js b/lib/matplotlib/backends/web_backend/js/mpl.js index 9e7959ec30e2..07923fb3f379 100644 --- a/lib/matplotlib/backends/web_backend/js/mpl.js +++ b/lib/matplotlib/backends/web_backend/js/mpl.js @@ -238,6 +238,10 @@ mpl.figure.prototype._init_canvas = function () { 'mouseup', on_mouse_event_closure('button_release') ); + rubberband_canvas.addEventListener( + 'dblclick', + on_mouse_event_closure('dblclick') + ); // Throttle sequential mouse events to 1 every 20ms. rubberband_canvas.addEventListener( 'mousemove',