Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f67d556

Browse filesBrowse files
authored
acquiring and releaseing keypresslock when textbox is being activated (#14343)
acquiring and releaseing keypresslock when textbox is being activated
2 parents a922901 + bd8dd06 commit f67d556
Copy full SHA for f67d556

File tree

Expand file treeCollapse file tree

1 file changed

+19
-10
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+19
-10
lines changed

‎lib/matplotlib/widgets.py

Copy file name to clipboardExpand all lines: lib/matplotlib/widgets.py
+19-10Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -856,23 +856,32 @@ def _notify_change_observers(self):
856856

857857
def begin_typing(self, x):
858858
self.capturekeystrokes = True
859-
# disable command keys so that the user can type without
860-
# command keys causing figure to be saved, etc
861-
self.reset_params = {}
862-
for key in self.params_to_disable:
863-
self.reset_params[key] = rcParams[key]
864-
rcParams[key] = []
859+
# Check for toolmanager handling the keypress
860+
if self.ax.figure.canvas.manager.key_press_handler_id is not None:
861+
# disable command keys so that the user can type without
862+
# command keys causing figure to be saved, etc
863+
self.reset_params = {}
864+
for key in self.params_to_disable:
865+
self.reset_params[key] = rcParams[key]
866+
rcParams[key] = []
867+
else:
868+
self.ax.figure.canvas.manager.toolmanager.keypresslock(self)
865869

866870
def stop_typing(self):
867871
notifysubmit = False
868872
# because _notify_submit_users might throw an error in the
869873
# user's code, we only want to call it once we've already done
870874
# our cleanup.
871875
if self.capturekeystrokes:
872-
# since the user is no longer typing,
873-
# reactivate the standard command keys
874-
for key in self.params_to_disable:
875-
rcParams[key] = self.reset_params[key]
876+
# Check for toolmanager handling the keypress
877+
if self.ax.figure.canvas.manager.key_press_handler_id is not None:
878+
# since the user is no longer typing,
879+
# reactivate the standard command keys
880+
for key in self.params_to_disable:
881+
rcParams[key] = self.reset_params[key]
882+
else:
883+
toolmanager = self.ax.figure.canvas.manager.toolmanager
884+
toolmanager.keypresslock.release(self)
876885
notifysubmit = True
877886
self.capturekeystrokes = False
878887
self.cursor.set_visible(False)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.