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

Function _mouse_handler

lib/matplotlib/backend_bases.py:1560–1594  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

1558
1559# Default callback for mouse events.
1560def _mouse_handler(event):
1561 # Dead-reckoning of button and key.
1562 if event.name == "button_press_event":
1563 event.canvas._button = event.button
1564 elif event.name == "button_release_event":
1565 event.canvas._button = None
1566 elif event.name == "motion_notify_event" and event.button is None:
1567 event.button = event.canvas._button
1568 if event.key is None:
1569 event.key = event.canvas._key
1570 # Emit axes_enter/axes_leave.
1571 if event.name == "motion_notify_event":
1572 last_ref = LocationEvent._last_axes_ref
1573 last_axes = last_ref() if last_ref else None
1574 if last_axes != event.inaxes:
1575 if last_axes is not None:
1576 # Create a synthetic LocationEvent for the axes_leave_event.
1577 # Its inaxes attribute needs to be manually set (because the
1578 # cursor is actually *out* of that Axes at that point); this is
1579 # done with the internal _set_inaxes method which ensures that
1580 # the xdata and ydata attributes are also correct.
1581 try:
1582 canvas = last_axes.get_figure(root=True).canvas
1583 leave_event = LocationEvent(
1584 "axes_leave_event", canvas,
1585 event.x, event.y, event.guiEvent,
1586 modifiers=event.modifiers)
1587 leave_event._set_inaxes(last_axes)
1588 canvas.callbacks.process("axes_leave_event", leave_event)
1589 except Exception:
1590 pass # The last canvas may already have been torn down.
1591 if event.inaxes is not None:
1592 event.canvas.callbacks.process("axes_enter_event", event)
1593 LocationEvent._last_axes_ref = (
1594 weakref.ref(event.inaxes) if event.inaxes else None)
1595
1596
1597def _get_renderer(figure, print_method=None):

Callers

nothing calls this directly

Calls 4

_set_inaxesMethod · 0.95
LocationEventClass · 0.85
processMethod · 0.80
get_figureMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…