diff options
author | pazz <patricktotzke@gmail.com> | 2011-08-06 10:09:56 +0100 |
---|---|---|
committer | pazz <patricktotzke@gmail.com> | 2011-08-06 10:09:56 +0100 |
commit | bb0e91ec4709164c8cf7124cbde060de551790ef (patch) | |
tree | a71509be806f0e6ca480c33d41e3c76461ce067c | |
parent | 982016b885c53fe5828a7fbff17fbc2c216f4bf2 (diff) |
deep focus. needed for select in threadbuffer
-rw-r--r-- | alot/ui.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -160,6 +160,18 @@ class UI: self.current_buffer.rebuild() self.update() + def get_deep_focus(self, startfrom=None): + """returns focussed leaf in the widget tree""" + if not startfrom: + startfrom = self.current_buffer + if 'get_focus' in dir(startfrom): + focus = startfrom.get_focus() + if isinstance(focus, tuple): + focus = focus[0] + if isinstance(focus, urwid.Widget): + return self.get_deep_focus(startfrom=focus) + return startfrom + def get_buffers_of_type(self, t): return filter(lambda x: isinstance(x, t), self.buffers) |