@@ -1517,6 +1517,9 @@ class MouseEvent(LocationEvent):
15171517 *step*
15181518 number of scroll steps (positive for 'up', negative for 'down')
15191519
1520+ *modifiers*
1521+ modifier keys depressed when mouse event triggered
1522+
15201523
15211524 Example usage::
15221525
@@ -1534,9 +1537,10 @@ def on_press(event):
15341537 xdata = None # x coord of mouse in data coords
15351538 ydata = None # y coord of mouse in data coords
15361539 step = None # scroll steps for scroll events
1540+ modifiers = None # depressed modifier keys
15371541
15381542 def __init__ (self , name , canvas , x , y , button = None , key = None ,
1539- step = 0 , dblclick = False , guiEvent = None ):
1543+ step = 0 , dblclick = False , guiEvent = None , modifiers = None ):
15401544 """
15411545 x, y in figure coords, 0,0 = bottom, left
15421546 button pressed None, 1, 2, 3, 'up', 'down'
@@ -1546,6 +1550,7 @@ def __init__(self, name, canvas, x, y, button=None, key=None,
15461550 self .key = key
15471551 self .step = step
15481552 self .dblclick = dblclick
1553+ self .modifiers = modifiers
15491554
15501555 def __str__ (self ):
15511556 return ("MPL MouseEvent: xy=(%d,%d) xydata=(%s,%s) button=%s " +
@@ -1886,7 +1891,7 @@ def scroll_event(self, x, y, step, guiEvent=None):
18861891 step = step , guiEvent = guiEvent )
18871892 self .callbacks .process (s , mouseevent )
18881893
1889- def button_press_event (self , x , y , button , dblclick = False , guiEvent = None ):
1894+ def button_press_event (self , x , y , button , dblclick = False , modifiers = None , guiEvent = None ):
18901895 """
18911896 Backend derived classes should call this function on any mouse
18921897 button press. x,y are the canvas coords: 0,0 is lower, left.
@@ -1898,8 +1903,9 @@ def button_press_event(self, x, y, button, dblclick=False, guiEvent=None):
18981903 """
18991904 self ._button = button
19001905 s = 'button_press_event'
1906+
19011907 mouseevent = MouseEvent (s , self , x , y , button , self ._key ,
1902- dblclick = dblclick , guiEvent = guiEvent )
1908+ dblclick = dblclick , modifiers = modifiers , guiEvent = guiEvent )
19031909 self .callbacks .process (s , mouseevent )
19041910
19051911 def button_release_event (self , x , y , button , guiEvent = None ):
0 commit comments