@@ -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