MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / MouseEvent

Class MouseEvent

lib/matplotlib/backend_bases.py:1323–1445  ·  view source on GitHub ↗

A mouse event ('button_press_event', 'button_release_event', \ 'scroll_event', 'motion_notify_event'). A MouseEvent has a number of special attributes in addition to those defined by the parent `Event` and `LocationEvent` classes. Attributes ---------- button : None or `Mo

Source from the content-addressed store, hash-verified

1321
1322
1323class MouseEvent(LocationEvent):
1324 """
1325 A mouse event ('button_press_event', 'button_release_event', \
1326'scroll_event', 'motion_notify_event').
1327
1328 A MouseEvent has a number of special attributes in addition to those
1329 defined by the parent `Event` and `LocationEvent` classes.
1330
1331 Attributes
1332 ----------
1333 button : None or `MouseButton` or {'up', 'down'}
1334 The button pressed. 'up' and 'down' are used for scroll events.
1335
1336 Note that LEFT and RIGHT actually refer to the "primary" and
1337 "secondary" buttons, i.e. if the user inverts their left and right
1338 buttons ("left-handed setting") then the LEFT button will be the one
1339 physically on the right.
1340
1341 If this is unset, *name* is "scroll_event", and *step* is nonzero, then
1342 this will be set to "up" or "down" depending on the sign of *step*.
1343
1344 buttons : None or frozenset
1345 For 'motion_notify_event', the mouse buttons currently being pressed
1346 (a set of zero or more MouseButtons);
1347 for other events, None.
1348
1349 .. note::
1350 For 'motion_notify_event', this attribute is more accurate than
1351 the ``button`` (singular) attribute, which is obtained from the last
1352 'button_press_event' or 'button_release_event' that occurred within
1353 the canvas (and thus 1. be wrong if the last change in mouse state
1354 occurred when the canvas did not have focus, and 2. cannot report
1355 when multiple buttons are pressed).
1356
1357 This attribute is not set for 'button_press_event' and
1358 'button_release_event' because GUI toolkits are inconsistent as to
1359 whether they report the button state *before* or *after* the
1360 press/release occurred.
1361
1362 .. warning::
1363 On macOS, the Tk backends only report a single button even if
1364 multiple buttons are pressed.
1365
1366 key : None or str
1367 The key pressed when the mouse event triggered, e.g. 'shift'.
1368 See `KeyEvent`.
1369
1370 .. warning::
1371 This key is currently obtained from the last 'key_press_event' or
1372 'key_release_event' that occurred within the canvas. Thus, if the
1373 last change of keyboard state occurred while the canvas did not have
1374 focus, this attribute will be wrong. On the other hand, the
1375 ``modifiers`` attribute should always be correct, but it can only
1376 report on modifier keys.
1377
1378 step : float
1379 The number of scroll steps (positive for 'up', negative for 'down').
1380 This applies only to 'scroll_event' and defaults to 0 otherwise.

Callers 15

test_toolbar_zoom_panFunction · 0.90
_handle_mouseMethod · 0.90
motion_notify_eventMethod · 0.90
button_press_eventMethod · 0.90
button_release_eventMethod · 0.90
scroll_eventMethod · 0.90
scroll_event_windowsMethod · 0.90
scroll_eventMethod · 0.90
button_press_eventMethod · 0.90
button_release_eventMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_toolbar_zoom_panFunction · 0.72
test_pickFunction · 0.72
test_interactive_zoomFunction · 0.72
test_interactive_panFunction · 0.72
test_containsFunction · 0.72
test_annotation_containsFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…