# HG changeset patch # User Goffi # Date 1410192891 -7200 # Node ID f36d7068a44bfb8b93d0844dd9a2156d462cac44 # Parent 4be53c14845e5cad8a16a69cf7906917c520aea9 Primitivus: fixed focus in ContactList: current behavious is temporary and will need to be rethinked a bit: if FOCUS_SWITCH is pressed, the focus change on top widget, if FOCUS_UP/DOWN is pressed, focus will throught contact list. diff -r 4be53c14845e -r f36d7068a44b frontends/src/primitivus/contact_list.py --- a/frontends/src/primitivus/contact_list.py Mon Sep 08 16:53:41 2014 +0200 +++ b/frontends/src/primitivus/contact_list.py Mon Sep 08 18:14:51 2014 +0200 @@ -26,6 +26,8 @@ from sat_frontends.primitivus.status import StatusBar from sat_frontends.primitivus.constants import Const from sat_frontends.primitivus.keys import action_key_map as a_key +from sat.core import log as logging +log = logging.getLogger(__name__) class ContactList(urwid.WidgetWrap, QuickContactList): @@ -42,7 +44,7 @@ #we now build the widget self.host.status_bar = StatusBar(host) - self.frame = urwid.Frame(self.__buildList(), None, self.host.status_bar) + self.frame = sat_widgets.FocusFrame(self.__buildList(), None, self.host.status_bar) self.main_widget = sat_widgets.LabelLine(self.frame, sat_widgets.SurroundedText(_("Contacts"))) urwid.WidgetWrap.__init__(self, self.main_widget) if on_click: @@ -65,6 +67,12 @@ self.update() def keypress(self, size, key): + # FIXME: we have a temporary behaviour here: FOCUS_SWITCH change focus globally in the parent, + # and FOCUS_UP/DOWN is transwmitter to parent if we are respectively on the first or last element + if key in sat_widgets.FOCUS_KEYS: + if (key == a_key['FOCUS_SWITCH'] or (key == a_key['FOCUS_UP'] and self.frame.focus_position == 'body') or + (key == a_key['FOCUS_DOWN'] and self.frame.focus_position == 'footer')): + return key if key == a_key['STATUS_HIDE']: #user wants to (un)hide contacts' statuses self.show_status = not self.show_status self.update()