def mouse_action(self, event):
""" Mouse event handler
:param event: event to handle
"""
pos = event.pos
if self.selected and not(self.last_knob_position < pos[0] < self.last_knob_position + self.knob_width and pos[1] > self.bounding_box.y) and event.type != pygame.KEYUP:
return
button_press_simulation = getattr(event, "p", None)
if event.type == pygame.MOUSEBUTTONUP and self.clicked:
self.release_action(pos)
elif event.type == pygame.MOUSEBUTTONDOWN and self.bounding_box.collidepoint(pos):
self.press_action()
elif event.type == pygame.MOUSEMOTION and (pygame.mouse.get_pressed()[0] or button_press_simulation) and self.bounding_box.collidepoint(pos) and self.clicked:
self.motion_action(pos)
评论列表
文章目录