primitivus (profile manager): added FOCUS_UP and FOCUS_DOWN management
This commit is contained in:
parent
67af90d334
commit
a1b79a7296
1 changed files with 16 additions and 2 deletions
|
|
@ -54,8 +54,8 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
connect_button = urwid.Button(_("Connect"), self.onConnectProfile)
|
||||
|
||||
#we now build the widget
|
||||
body_content = urwid.SimpleListWalker([buttons_flow,self.list_profile,divider,self.login_wid, self.pass_wid, connect_button])
|
||||
frame_body = urwid.ListBox(body_content)
|
||||
list_walker = urwid.SimpleFocusListWalker([buttons_flow,self.list_profile,divider,self.login_wid, self.pass_wid, connect_button])
|
||||
frame_body = urwid.ListBox(list_walker)
|
||||
frame = urwid.Frame(frame_body,urwid.AttrMap(urwid.Text(_("Profile Manager"),align='center'),'title'))
|
||||
self.main_widget = urwid.LineBox(frame)
|
||||
urwid.WidgetWrap.__init__(self, self.main_widget)
|
||||
|
|
@ -64,6 +64,20 @@ class ProfileManager(urwid.WidgetWrap):
|
|||
if key == a_key['APP_QUIT']:
|
||||
self.host.onExit()
|
||||
raise urwid.ExitMainLoop()
|
||||
elif key in (a_key['FOCUS_UP'], a_key['FOCUS_DOWN']):
|
||||
focus_diff = 1 if key==a_key['FOCUS_DOWN'] else -1
|
||||
list_box = self.main_widget.base_widget.body
|
||||
current_focus = list_box.body.get_focus()[1]
|
||||
if current_focus is None:
|
||||
return
|
||||
while True:
|
||||
current_focus += focus_diff
|
||||
if current_focus < 0 or current_focus >= len(list_box.body):
|
||||
break
|
||||
if list_box.body[current_focus].selectable():
|
||||
list_box.set_focus(current_focus, 'above' if focus_diff == 1 else 'below')
|
||||
list_box._invalidate()
|
||||
return
|
||||
return super(ProfileManager, self).keypress(size, key)
|
||||
|
||||
def __refillProfiles(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue