@@ -680,7 +680,7 @@ def __init__(self, ax, label, initial='',
680
680
self .params_to_disable += [key ]
681
681
682
682
self .text = initial
683
- self .label = ax .text (0.0 , 0.5 , label ,
683
+ self .label = ax .text (- 0.01 , 0.5 , label ,
684
684
verticalalignment = 'center' ,
685
685
10000
horizontalalignment = 'right' ,
686
686
transform = ax .transAxes )
@@ -726,7 +726,7 @@ def _make_text_disp(self, string):
726
726
def _rendercursor (self ):
727
727
# this is a hack to figure out where the cursor should go.
728
728
# we draw the text up to where the cursor should go, measure
729
- # save its dimensions, draw the real text, then put the cursor
729
+ # and save its dimensions, draw the real text, then put the cursor
730
730
# at the saved dimensions
731
731
732
732
widthtext = self .text [:self .cursor_index ]
@@ -798,38 +798,51 @@ def _keypress(self, event):
798
798
func (self .text )
799
799
if key == "enter" :
800
800
self ._notify_submit_observers ()
801
+
802
+ def begin_typing (x ):
803
+ self .capturekeystrokes = True
804
+ #disable command keys so that the user can type without
805
+ #command keys causing figure to be saved, etc
806
+ self .reset_params = {}
807
+ for key in self .params_to_disable :
808
+ self .reset_params [key ] = rcParams [key ]
809
+ rcParams [key ] = []
810
+ #now, we have to figure out where the cursor goes.
811
+ #approximate it based on assuming all characters the same length
812
+ print (x )
813
+ self .cursor_index = len (self .text )
814
+ self ._rendercursor ()
815
+
816
+ def stop_typing ():
817
+ notifysubmit = False
818
+ # because _notify_submit_users might throw an error in the
819
+ # user's code, we only want to call it once we've already done
820
+ # our cleanup.
821
+ if self .capturekeystrokes :
822
+ #since the user is no longer typing,
823
+ #reactivate the standard command keys
824
+ for key in self .params_to_disable :
825
+ rcParams [key ] = self .reset_params [key ]
826
+ notifysubmit = True
827
+ self .capturekeystrokes = False
828
+ self .cursor .set_visible (False )
829
+ self .ax .figure .canvas .draw ()
830
+ if notifysubmit :
831
+ self ._notify_submit_observers ()
801
832
833
+
802
834
def _click (self , event ):
803
835
if self .ignore (event ):
804
836
return
805
837
if event .inaxes != self .ax :
806
- notifysubmit = False
807
- # because _notify_submit_users might throw an error in the
808
- # user's code, we only want to call it once we've already done
809
- # our cleanup.
810
- if self .capturekeystrokes :
811
- for key in self .params_to_disable :
812
- rcParams [key ] = self .reset_params [key ]
813
- notifysubmit = True
814
- self .capturekeystrokes = False
815
- self .cursor .set_visible (False )
816
- self .ax .figure .canvas .draw ()
817
-
818
- if notifysubmit :
819
- self ._notify_submit_observers ()
838
+ self .stop_typing ()
820
839
return
821
840
if not self .eventson :
822
841
return
823
842
if event .canvas .mouse_grabber != self .ax :
824
843
event .canvas .grab_mouse (self .ax )
825
844
if not (self .capturekeystrokes ):
826
- self .capturekeystrokes = True
827
- self .reset_params = {}
828
- for key in self .params_to_disable :
829
- self .reset_params [key ] = rcParams [key ]
830
- rcParams [key ] = []
831
- self .cursor_index = len (self .text )
832
- self ._rendercursor ()
845
+ self .begin_typing (exent .x )
833
846
834
847
def _motion (self , event ):
835
848
if self .ignore (event ):
0 commit comments