X-Git-Url: https://svn.cri.ensmp.fr/git/minwii.git/blobdiff_plain/855472fc15f855881b98149078b6645309278b8a..1949ce08d8bd0e485280de3039c1c103522d7c2d:/src/app/widgets/cursors.py?ds=sidebyside diff --git a/src/app/widgets/cursors.py b/src/app/widgets/cursors.py index 6b0d6e8..3ac9c43 100755 --- a/src/app/widgets/cursors.py +++ b/src/app/widgets/cursors.py @@ -10,7 +10,7 @@ import pygame import os from eventutils import EventHandlerMixin, event_handler from itertools import cycle -from pygame.locals import MOUSEBUTTONDOWN, MOUSEBUTTONUP, USEREVENT +from pygame.locals import USEREVENT TIMEOUT = USEREVENT + 1 class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin): @@ -30,6 +30,7 @@ class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin): def __init__(self, theme='black', duration=75, blink=True): pygame.sprite.Sprite.__init__(self) + pygame.mouse.set_visible(False) imagesPath, images = WarpingCursor._get_theme_images(theme) flashImage = images.pop(images.index('flash.png')) flashImagePath = os.path.sep.join([imagesPath, flashImage]) @@ -49,7 +50,6 @@ class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin): self.image = self.images[0] self.rect = pygame.Rect((0,0), (self.width, self.height)) - self.update() self.blink = blink if blink : @@ -67,19 +67,20 @@ class WarpingCursor(pygame.sprite.Sprite, EventHandlerMixin): def loadNext(self, event) : if self.blink : self.image = self.iterator.next() - self.update() - @event_handler(MOUSEBUTTONDOWN) + @event_handler(pygame.MOUSEBUTTONDOWN) def flashOn(self, event) : self.blink=False self.image = self.flashImage - self.update() - @event_handler(MOUSEBUTTONUP) + @event_handler(pygame.MOUSEBUTTONUP) def flashOff(self, event) : self.blink = True self.loadNext(event) - - def update(self) : - surface = pygame.display.get_surface() - surface.blit(self.image, self.rect) + + @event_handler(pygame.MOUSEMOTION) + def move(self, event) : + x, y = event.rel + self.rect.centerx += x + self.rect.centery += y + #self.rect.move_ip(*rel)