def mouse_move(self, event): # ignore event when image is not yet drawn try: self.image except AttributeError: return self.set_status(mouse=self.pdfpoint(event.position)) # choose and set cursor for selection changing if self.selection is not None: left, top, right, bottom = self.selection x, y = event.position sensivity = 10 if near((left, top), (x, y), sensivity): # corners self.cursor = sizer_nw_se self.changespec = dict(istop=True, isleft=True) elif near((right, bottom), (x, y), sensivity): self.cursor = sizer_nw_se self.changespec = dict(istop=False, isleft=False) elif near((right, top), (x, y), sensivity): self.cursor = sizer_ne_sw self.changespec = dict(istop=True, isleft=False) elif near((left, bottom), (x, y), sensivity): self.cursor = sizer_ne_sw self.changespec = dict(istop=False, isleft=True) elif abs(x-left) <= sensivity and top < y < bottom: # sides self.cursor = sizer_w_e self.changespec = dict(isleft=True) elif abs(x-right) <= sensivity and top < y < bottom: self.cursor = sizer_w_e self.changespec = dict(isleft=False) elif abs(y-top) <= sensivity and left < x < right: self.cursor = sizer_n_s self.changespec = dict(istop=True) elif abs(y-bottom) <= sensivity and left < x < right: self.cursor = sizer_n_s self.changespec = dict(istop=False) elif pt_in_rect((x, y), self.selection): # inside self.cursor = finger else: # elsewhere self.cursor = crosshair
def contains(self, x, y): return pt_in_rect((x, y), self.rect)