Update the slider position.
(self, event)
| 914 | |
| 915 | @_call_with_reparented_event |
| 916 | def _update(self, event): |
| 917 | """Update the slider position.""" |
| 918 | if self.ignore(event) or event.button != 1: |
| 919 | return |
| 920 | |
| 921 | if event.name == "button_press_event" and self.ax.contains(event)[0]: |
| 922 | self.drag_active = True |
| 923 | event.canvas.grab_mouse(self.ax) |
| 924 | |
| 925 | if not self.drag_active: |
| 926 | return |
| 927 | |
| 928 | if (event.name == "button_release_event" |
| 929 | or event.name == "button_press_event" and not self.ax.contains(event)[0]): |
| 930 | self.drag_active = False |
| 931 | event.canvas.release_mouse(self.ax) |
| 932 | self._active_handle = None |
| 933 | return |
| 934 | |
| 935 | # determine which handle was grabbed |
| 936 | handle_index = np.argmin(np.abs( |
| 937 | [h.get_xdata()[0] - event.xdata for h in self._handles] |
| 938 | if self.orientation == "horizontal" else |
| 939 | [h.get_ydata()[0] - event.ydata for h in self._handles])) |
| 940 | handle = self._handles[handle_index] |
| 941 | |
| 942 | # these checks ensure smooth behavior if the handles swap which one |
| 943 | # has a higher value. i.e. if one is dragged over and past the other. |
| 944 | if handle is not self._active_handle: |
| 945 | self._active_handle = handle |
| 946 | |
| 947 | self._update_val_from_pos( |
| 948 | event.xdata if self.orientation == "horizontal" else event.ydata) |
| 949 | |
| 950 | def _format(self, val): |
| 951 | """Pretty-print *val*.""" |
nothing calls this directly
no test coverage detected