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

Method _release

lib/matplotlib/widgets.py:3523–3569  ·  view source on GitHub ↗

Button release event handler.

(self, event)

Source from the content-addressed store, hash-verified

3521
3522 @_call_with_reparented_event
3523 def _release(self, event):
3524 """Button release event handler."""
3525 self._set_cursor(backend_tools.Cursors.POINTER)
3526 if not self._interactive:
3527 self._selection_artist.set_visible(False)
3528
3529 if (self._active_handle is None and self._selection_completed and
3530 self.ignore_event_outside):
3531 return
3532
3533 # update the eventpress and eventrelease with the resulting extents
3534 x0, x1, y0, y1 = self.extents
3535 self._eventpress.xdata = x0
3536 self._eventpress.ydata = y0
3537 xy0 = self.ax.transData.transform([x0, y0])
3538 self._eventpress.x, self._eventpress.y = xy0
3539
3540 self._eventrelease.xdata = x1
3541 self._eventrelease.ydata = y1
3542 xy1 = self.ax.transData.transform([x1, y1])
3543 self._eventrelease.x, self._eventrelease.y = xy1
3544
3545 # calculate dimensions of box or line
3546 if self.spancoords == 'data':
3547 spanx = abs(self._eventpress.xdata - self._eventrelease.xdata)
3548 spany = abs(self._eventpress.ydata - self._eventrelease.ydata)
3549 elif self.spancoords == 'pixels':
3550 spanx = abs(self._eventpress.x - self._eventrelease.x)
3551 spany = abs(self._eventpress.y - self._eventrelease.y)
3552 else:
3553 _api.check_in_list(['data', 'pixels'],
3554 spancoords=self.spancoords)
3555 # check if drawn distance (if it exists) is not too small in
3556 # either x or y-direction
3557 if spanx <= self.minspanx or spany <= self.minspany:
3558 if self._selection_completed:
3559 # Call onselect, only when the selection is already existing
3560 self.onselect(self._eventpress, self._eventrelease)
3561 self._clear_without_update()
3562 else:
3563 self.onselect(self._eventpress, self._eventrelease)
3564 self._selection_completed = True
3565
3566 self.update()
3567 self._active_handle = None
3568 self._extents_on_press = None
3569 return False
3570
3571 def _get_action(self):
3572 state = self._state

Callers

nothing calls this directly

Calls 6

_set_cursorMethod · 0.80
set_visibleMethod · 0.45
transformMethod · 0.45
onselectMethod · 0.45
_clear_without_updateMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected