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

Function click_and_drag

lib/matplotlib/testing/widgets.py:97–120  ·  view source on GitHub ↗

Helper to simulate a mouse drag operation. Parameters ---------- tool : `~matplotlib.widgets.Widget` start : [float, float] Starting point in data coordinates. end : [float, float] End point in data coordinates. key : None or str An optional key

(tool, start, end, key=None)

Source from the content-addressed store, hash-verified

95
96
97def click_and_drag(tool, start, end, key=None):
98 """
99 Helper to simulate a mouse drag operation.
100
101 Parameters
102 ----------
103 tool : `~matplotlib.widgets.Widget`
104 start : [float, float]
105 Starting point in data coordinates.
106 end : [float, float]
107 End point in data coordinates.
108 key : None or str
109 An optional key that is pressed during the whole operation
110 (see also `.KeyEvent`).
111 """
112 ax = tool.ax
113 if key is not None: # Press key
114 KeyEvent._from_ax_coords("key_press_event", ax, start, key)._process()
115 # Click, move, and release mouse
116 MouseEvent._from_ax_coords("button_press_event", ax, start, 1)._process()
117 MouseEvent._from_ax_coords("motion_notify_event", ax, end, 1)._process()
118 MouseEvent._from_ax_coords("button_release_event", ax, end, 1)._process()
119 if key is not None: # Release key
120 KeyEvent._from_ax_coords("key_release_event", ax, end, key)._process()

Calls 2

_processMethod · 0.80
_from_ax_coordsMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…