File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -531,10 +531,9 @@ def onAddText(self):
531
531
# MPL style names
532
532
styles = ['normal' , 'italic' , 'oblique' ]
533
533
# QFont::Style maps directly onto the above
534
- try :
535
- mpl_font .set_style (styles [extra_font .style ()])
536
- except :
537
- pass
534
+ # Get an index of the font style which we can then lookup in the styles list.
535
+ font_index = extra_font .style ().value
536
+ mpl_font .set_style (styles [font_index ])
538
537
539
538
if len (extra_text ) > 0 :
540
539
new_text = self .ax .text (pos_x ,
@@ -919,6 +918,13 @@ def onMplMouseDown(self, event):
919
918
"""
920
919
Left button down and ready to drag
921
920
"""
921
+ # Before checking if this mouse click is a left click, we need to update the position of the mouse regardless as
922
+ # this may be needed by other events (e.g. adding text)
923
+ try :
924
+ self .x_click = float (event .xdata ) # / size_x
925
+ self .y_click = float (event .ydata ) # / size_y
926
+ except :
927
+ self .position = None
922
928
# Check that the LEFT button was pressed
923
929
if event .button != 1 :
924
930
return
@@ -930,11 +936,6 @@ def onMplMouseDown(self, event):
930
936
return
931
937
if event .inaxes is None :
932
938
return
933
- try :
934
- self .x_click = float (event .xdata ) # / size_x
935
- self .y_click = float (event .ydata ) # / size_y
936
- except :
937
- self .position = None
938
939
939
940
x_str = GuiUtils .formatNumber (self .x_click )
940
941
y_str = GuiUtils .formatNumber (self .y_click )
You can’t perform that action at this time.
0 commit comments