Mercurial > mamba
changeset 109:dc0b0be7e2f6
Move mouse focussing to within Container
author | Stefano Rivera <stefano@rivera.za.net> |
---|---|
date | Sun, 11 Sep 2011 20:15:32 +0200 |
parents | 8cac61396cef |
children | e6299eb296ce |
files | mamba/widgets/base.py |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mamba/widgets/base.py Sun Sep 11 20:06:51 2011 +0200 +++ b/mamba/widgets/base.py Sun Sep 11 20:15:32 2011 +0200 @@ -20,19 +20,6 @@ self.callbacks[eventtype].append((callback, args)) def event(self, ev): - if ev.type == MOUSEBUTTONDOWN and self.focussable: - root = self - while root.parent is not None: - root = root.parent - root.defocus() - widget = self - while widget.parent is not None: - parent = widget.parent - if isinstance(parent, Container): - parent.focussed_child = parent.children.index(widget) - widget = parent - self.focussed = True - for callback, args in self.callbacks[ev.type]: if callback(ev, self, *args): return True @@ -57,8 +44,23 @@ if ev.type in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN): for child in self.children: if child.rect.collidepoint(ev.pos): + if ev.type == MOUSEBUTTONDOWN and child.focussable: + root = self + while root.parent is not None: + root = root.parent + root.defocus() + widget = child + while widget.parent is not None: + parent = widget.parent + if isinstance(parent, Container): + idx = parent.children.index(widget) + parent.focussed_child = idx + widget = parent + child.focussed = True + if child.event(ev): return True + if ev.type == KEYDOWN: for child in self.children: if child.focussed: