FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix key reporting in pick events by QuLogic · Pull Request #24250 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 2 additions & 4 deletions lib/matplotlib/figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2445,10 +2445,6 @@ def __init__(self,
# pickling.
self._canvas_callbacks = cbook.CallbackRegistry(
signals=FigureCanvasBase.events)
self._button_pick_id = self._canvas_callbacks._connect_picklable(
'button_press_event', self.pick)
self._scroll_pick_id = self._canvas_callbacks._connect_picklable(
'scroll_event', self.pick)
connect = self._canvas_callbacks._connect_picklable
self._mouse_key_ids = [
connect('key_press_event', backend_bases._key_handler),
Expand All @@ -2459,6 +2455,8 @@ def __init__(self,
connect('scroll_event', backend_bases._mouse_handler),
connect('motion_notify_event', backend_bases._mouse_handler),
]
self._button_pick_id = connect('button_press_event', self.pick)
self._scroll_pick_id = connect('scroll_event', self.pick)

if figsize is None:
figsize = mpl.rcParams['figure.figsize']
Expand Down
18 changes: 12 additions & 6 deletions lib/matplotlib/tests/test_backend_bases.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from matplotlib import path, transforms
from matplotlib.backend_bases import (
FigureCanvasBase, LocationEvent, MouseButton, MouseEvent,
FigureCanvasBase, KeyEvent, LocationEvent, MouseButton, MouseEvent,
NavigationToolbar2, RendererBase)
from matplotlib.backend_tools import RubberbandBase
from matplotlib.figure import Figure
Expand Down Expand Up @@ -124,12 +124,18 @@ def test_pick():
fig = plt.figure()
fig.text(.5, .5, "hello", ha="center", va="center", picker=True)
fig.canvas.draw()

picks = []
fig.canvas.mpl_connect("pick_event", lambda event: picks.append(event))
start_event = MouseEvent(
"button_press_event", fig.canvas, *fig.transFigure.transform((.5, .5)),
MouseButton.LEFT)
fig.canvas.callbacks.process(start_event.name, start_event)
def handle_pick(event):
assert event.mouseevent.key == "a"
picks.append(event)
fig.canvas.mpl_connect("pick_event", handle_pick)

KeyEvent("key_press_event", fig.canvas, "a")._process()
MouseEvent("button_press_event", fig.canvas,
*fig.transFigure.transform((.5, .5)),
MouseButton.LEFT)._process()
KeyEvent("key_release_event", fig.canvas, "a")._process()
assert len(picks) == 1


Expand Down

Back | FazBrowse Home | New Git URL