def handle(self, event):
if event.type == pygame.MOUSEMOTION or event.type == pygame.MOUSEBUTTONDOWN or event.type == pygame.MOUSEBUTTONUP:
pos = [event.pos[0] - self.mainloop.game_board.layout.dialogwnd_pos[0],
event.pos[1] - self.mainloop.game_board.layout.dialogwnd_pos[1]]
found = False
for each in self.elements:
if each.rect.topleft[0] + each.rect.width >= pos[0] >= each.rect.topleft[0] and each.rect.topleft[
1] + each.rect.height >= pos[1] >= each.rect.topleft[1]:
each.handle(event)
found = True
if not found:
for each in self.elements:
each.mouse_out()
else:
pass
评论列表
文章目录