X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/46f3ffd7fdde386f41020171b5733e55a8e64a85..cb25c1d036a07cb8dee77be1c3ba7a733e8190a4:/src/minwii/widgets/cursors.py?ds=sidebyside diff --git a/src/minwii/widgets/cursors.py b/src/minwii/widgets/cursors.py index fa1f673..4edc2dc 100755 --- a/src/minwii/widgets/cursors.py +++ b/src/minwii/widgets/cursors.py @@ -10,7 +10,7 @@ import pygame import os from threading import Thread import time -from eventutils import EventHandlerMixin, event_handler +from minwii.eventutils import EventHandlerMixin, event_handler from itertools import cycle class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): @@ -48,6 +48,7 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): self.duration = duration self.image = self.images[0] + self.pressed = False # workarround cursor alignement problem pygame.event.set_blocked(pygame.MOUSEMOTION) pygame.mouse.set_pos(pygame.mouse.get_pos()) @@ -91,6 +92,7 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): self.dirty = 1 self._blinking = False self.image = self.flashImage + self.pressed = True @event_handler(pygame.MOUSEBUTTONUP) def flashOff(self, event) : @@ -99,11 +101,14 @@ class WarpingCursor(pygame.sprite.DirtySprite, EventHandlerMixin): self._blinking = True else : self.image = self.images[0] + self.pressed = False @event_handler(pygame.MOUSEMOTION) def move(self, event) : self.dirty = 1 - self.rect.move_ip(event.rel) + x, y = pygame.mouse.get_pos() + rel = (x - self.rect.centerx, y - self.rect.centery) + self.rect.move_ip(rel) def setPosition(self, pos) : self.dirty = 1 @@ -127,4 +132,4 @@ class ForeverTimer(Thread) : time.sleep(self.duration) def stop(self) : - self.running = False \ No newline at end of file + self.running = False