Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9a9ad6e

Browse files
author
Federico Ariza
committed
acquiring and releaseing keypresslock when textbox is being activated
1 parent 30354dd commit 9a9ad6e

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

lib/matplotlib/widgets.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -856,23 +856,29 @@ 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+
if rcParams['toolbar'] != 'toolmanager':
860+
# disable command keys so that the user can type without
861+
# command keys causing figure to be saved, etc
862+
self.reset_params = {}
863+
for key in self.params_to_disable:
864+
self.reset_params[key] = rcParams[key]
865+
rcParams[key] = []
866+
else:
867+
self.ax.figure.canvas.manager.toolmanager.keypresslock(self)
865868

866869
def stop_typing(self):
867870
notifysubmit = False
868871
# because _notify_submit_users might throw an error in the
869872
# user's code, we only want to call it once we've already done
870873
# our cleanup.
871874
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]
875+
if rcParams['toolbar'] != 'toolmanager':
876+
# since the user is no longer typing,
877+
# reactivate the standard command keys
878+
for key in self.params_to_disable:
879+
rcParams[key] = self.reset_params[key]
880+
else:
881+
self.ax.figure.canvas.manager.toolmanager.keypresslock.release(self)
876882
notifysubmit = True
877883
self.capturekeystrokes = False
878884
self.cursor.set_visible(False)

0 commit comments

Comments
 (0)