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.
This commit is contained in:
parent
2a0857fe4f
commit
ab8bc3cddd
1 changed files with 9 additions and 1 deletions
|
|
@ -26,6 +26,8 @@ from sat_frontends.tools.jid import JID
|
|||
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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
|
||||
#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 @@ class ContactList(urwid.WidgetWrap, QuickContactList):
|
|||
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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue