'Cursor move event handler'

def _onmove(self, event):

    if (self._active_handle_idx >= 0):
        idx = self._active_handle_idx
        (self._xs[idx], self._ys[idx]) = (event.xdata, event.ydata)
        if ((idx == 0) and self._polygon_completed):
            (self._xs[(-1)], self._ys[(-1)]) = (event.xdata, event.ydata)
    elif ((u'move_all' in self.state) and self.eventpress):
        dx = (event.xdata - self.eventpress.xdata)
        dy = (event.ydata - self.eventpress.ydata)
        for k in range(len(self._xs)):
            self._xs[k] = (self._xs_at_press[k] + dx)
            self._ys[k] = (self._ys_at_press[k] + dy)
    elif (self._polygon_completed or (u'move_vertex' in self.state) or (u'move_all' in self.state)):
        return
    else:
        (x0, y0) = self.line.get_transform().transform((self._xs[0], self._ys[0]))
        v0_dist = np.sqrt((((x0 - event.x) ** 2) + ((y0 - event.y) ** 2)))
        if ((len(self._xs) > 3) and (v0_dist < self.vertex_select_radius)):
            (self._xs[(-1)], self._ys[(-1)]) = (self._xs[0], self._ys[0])
        else:
            (self._xs[(-1)], self._ys[(-1)]) = (event.xdata, event.ydata)
    self._draw_polygon()
