Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6519f0

Browse files
authored
Merge pull request #12199 from anntzer/blocking-input-button-add
Allow disabling specific mouse actions in blocking_input
2 parents 927c920 + 5f29877 commit d6519f0

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

lib/matplotlib/blocking_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def mouse_event(self):
135135
self.mouse_event_pop(event)
136136
elif button == self.button_stop:
137137
self.mouse_event_stop(event)
138-
else:
138+
elif button == self.button_add:
139139
self.mouse_event_add(event)
140140

141141
def key_event(self):

lib/matplotlib/figure.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,11 +2181,20 @@ def ginput(self, n=1, timeout=30, show_clicks=True, mouse_add=1,
21812181
Wait until the user clicks *n* times on the figure, and return the
21822182
coordinates of each click in a list.
21832183
2184-
The buttons used for the various actions (adding points, removing
2185-
points, terminating the inputs) can be overridden via the
2186-
arguments *mouse_add*, *mouse_pop* and *mouse_stop*, that give
2187-
the associated mouse button: 1 for left, 2 for middle, 3 for
2188-
right.
2184+
There are three possible interactions:
2185+
2186+
- Add a point.
2187+
- Remove the most recently added point.
2188+
- Stop the interaction and return the points added so far.
2189+
2190+
The actions are assigned to mouse buttons via the arguments
2191+
*mouse_add*, *mouse_pop* and *mouse_stop*. Mouse buttons are defined
2192+
by the numbers:
2193+
2194+
- 1: left mouse button
2195+
- 2: middle mouse button
2196+
- 3: right mouse button
2197+
- None: no mouse button
21892198
21902199
Parameters
21912200
----------
@@ -2197,11 +2206,11 @@ def ginput(self, n=1, timeout=30, show_clicks=True, mouse_add=1,
21972206
will never timeout.
21982207
show_clicks : bool, optional, default: False
21992208
If True, show a red cross at the location of each click.
2200-
mouse_add : int, one of (1, 2, 3), optional, default: 1 (left click)
2209+
mouse_add : {1, 2, 3, None}, optional, default: 1 (left click)
22012210
Mouse button used to add points.
2202-
mouse_pop : int, one of (1, 2, 3), optional, default: 3 (right click)
2211+
mouse_pop : {1, 2, 3, None}, optional, default: 3 (right click)
22032212
Mouse button used to remove the most recently added point.
2204-
mouse_stop : int, one of (1, 2, 3), optional, default: 2 (middle click)
2213+
mouse_stop : {1, 2, 3, None}, optional, default: 2 (middle click)
22052214
Mouse button used to stop input.
22062215
22072216
Returns

0 commit comments

Comments
 (0)