Mercurial > pyntnclick
diff gamelib/cursor.py @ 139:a5972444ad1e
Improve cursor state handling, disable highlights on modal dialogs
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Tue, 24 Aug 2010 22:02:22 +0200 |
parents | b43599b7f8a2 |
children | a1162ea4ad67 |
line wrap: on
line diff
--- a/gamelib/cursor.py Tue Aug 24 21:52:45 2010 +0200 +++ b/gamelib/cursor.py Tue Aug 24 22:02:22 2010 +0200 @@ -27,6 +27,7 @@ self.highlight = pygame.Surface(self.rect.size) color = pygame.color.Color(255, 100, 100, 0) self.highlight.fill(color) + self.highlighted = False def update(self): pos = pygame.mouse.get_pos() @@ -34,9 +35,12 @@ self.rect.top = pos[1] - self.pointer_y def set_highlight(self, enable): - self.image = self.plain_image.copy() - if enable: - self.image.blit(self.highlight, self.highlight.get_rect(), None, pygame.BLEND_MULT) + if enable != self.highlighted: + self.highlighted = enable + self.image = self.plain_image.copy() + if enable: + self.image.blit(self.highlight, self.highlight.get_rect(), + None, pygame.BLEND_MULT) HAND = CursorSprite('hand.png', 12, 0) @@ -52,6 +56,12 @@ self._cursor_group = RenderUpdates() self._loaded_cursor = None + def enter_screen(self): + pygame.mouse.set_visible(0) + + def leave_screen(self): + pygame.mouse.set_visible(1) + def draw_all(self, _surface): Widget.draw_all(self, _surface) surface = self.get_root().surface