Mercurial > mamba
changeset 95:7a17c5b74148
Correctly handle nested Containers. Set focus on root container at first draw
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sun, 11 Sep 2011 19:17:57 +0200 |
parents | aba653f8383e |
children | 6c11991e23fb |
files | mamba/widgets/base.py |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mamba/widgets/base.py Sun Sep 11 19:16:16 2011 +0200 +++ b/mamba/widgets/base.py Sun Sep 11 19:17:57 2011 +0200 @@ -35,7 +35,6 @@ super(Container, self).__init__(rect) self.children = [] self.root = root - self.focussed = root self.focussable = True self.focussed_child = None @@ -94,8 +93,20 @@ child.focussed = True return True else: + if self.root: + # At the end, mark the last one as focussed, again + child = self.children[self.focussed_child] + if isinstance(child, Container): + if child.adjust_focus(-direction): + return True + child.focussed = True + else: + self.focussed_child = None return False def draw(self, surface): + if self.root and not self.focussed: + self.focussed = True + self.adjust_focus(1) for child in self.children: child.draw(surface)