# HG changeset patch # User Neil Muller # Date 1316299003 -7200 # Node ID bbb2e246d0ad028094143ca299b14ebca86124ea # Parent 8e8ee459f23e4eeeac5d8144eb658597851bf2db Add cursor'ish thingy thing diff -r 8e8ee459f23e -r bbb2e246d0ad mamba/widgets/text.py --- a/mamba/widgets/text.py Sun Sep 18 00:32:58 2011 +0200 +++ b/mamba/widgets/text.py Sun Sep 18 00:36:43 2011 +0200 @@ -29,6 +29,7 @@ if not isinstance(self.color, pygame.Color): self.color = pygame.Color(self.color) self.surface = self.font.render(self.text, True, self.color) + self.text_rect = self.surface.get_rect() width, height = self.surface.get_rect().size self.rect.width = max(self.rect.width, width) self.rect.height = max(self.rect.height, height) @@ -50,7 +51,7 @@ def prepare(self): super(TextButton, self).prepare() text = self.surface - text_rect = text.get_rect() + text_rect = self.text_rect self._focussed = self.focussed if self.disabled: color = pygame.Color('#666666') @@ -119,3 +120,12 @@ if self._focussed != self.focussed: self.prepare() super(EntryTextWidget, self).draw(surface) + if self.focussed: + text_rect = self.text_rect + # Warning, 00:30 AM code on the last Saturday + cur_start = text_rect.move( + (self.rect.left + 2, self.rect.top + 3)).topright + cur_end = text_rect.move( + (self.rect.left + 2, self.rect.top - 3)).bottomright + pygame.draw.line(surface, self.focus_color, + cur_start, cur_end, 2)