@@ -856,23 +856,32 @@ def _notify_change_observers(self):
856
856
857
857
def begin_typing (self , x ):
858
858
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 )
865
869
866
870
def stop_typing (self ):
867
871
notifysubmit = False
868
872
# because _notify_submit_users might throw an error in the
869
873
# user's code, we only want to call it once we've already done
870
874
# our cleanup.
871
875
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 )
876
885
notifysubmit = True
877
886
self .capturekeystrokes = False
878
887
self .cursor .set_visible (False )
0 commit comments