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

Method _set_active_handle

lib/matplotlib/widgets.py:3034–3058  ·  view source on GitHub ↗

Set active handle based on the location of the mouse event.

(self, event)

Source from the content-addressed store, hash-verified

3032 self._selection_artist.set_height(vmax - vmin)
3033
3034 def _set_active_handle(self, event):
3035 """Set active handle based on the location of the mouse event."""
3036 # Note: event.xdata/ydata in data coordinates, event.x/y in pixels
3037 e_idx, e_dist = self._edge_handles.closest(event.x, event.y)
3038
3039 # Prioritise center handle over other handles
3040 # Use 'C' to match the notation used in the RectangleSelector
3041 if 'move' in self._state:
3042 self._active_handle = 'C'
3043 elif e_dist > self.grab_range:
3044 # Not close to any handles
3045 self._active_handle = None
3046 if self.drag_from_anywhere and self._contains(event):
3047 # Check if we've clicked inside the region
3048 self._active_handle = 'C'
3049 self._extents_on_press = self.extents
3050 else:
3051 self._active_handle = None
3052 return
3053 else:
3054 # Closest to an edge handle
3055 self._active_handle = self._edge_order[e_idx]
3056
3057 # Save coordinates of rectangle at the start of handle movement.
3058 self._extents_on_press = self.extents
3059
3060 def _contains(self, event):
3061 """Return True if event is within the patch."""

Callers 1

_pressMethod · 0.95

Calls 2

_containsMethod · 0.95
closestMethod · 0.45

Tested by

no test coverage detected