Merge pull request #243 from CanonicalLtd/mwhudson/enter-next-field

have enter advance to the next focus item in piles and listboxes
This commit is contained in:
Michael Hudson-Doyle 2017-09-22 11:10:57 +12:00 committed by GitHub
commit 64ec13fc98
1 changed files with 4 additions and 0 deletions

View File

@ -95,8 +95,11 @@ class TabCyclingMixin:
else: else:
return key return key
enter_advancing_command_map = urwid.command_map.copy()
enter_advancing_command_map['enter'] = 'next selectable'
class TabCyclingPile(TabCyclingMixin, urwid.Pile): class TabCyclingPile(TabCyclingMixin, urwid.Pile):
_command_map = enter_advancing_command_map
pass pass
class TabCyclingColumns(TabCyclingMixin, urwid.Columns): class TabCyclingColumns(TabCyclingMixin, urwid.Columns):
@ -104,6 +107,7 @@ class TabCyclingColumns(TabCyclingMixin, urwid.Columns):
class TabCyclingListBox(urwid.ListBox): class TabCyclingListBox(urwid.ListBox):
_command_map = enter_advancing_command_map
# It feels like it ought to be possible to write TabCyclingMixin # It feels like it ought to be possible to write TabCyclingMixin
# so it works for a ListBox as well, but it seems to be just # so it works for a ListBox as well, but it seems to be just
# awkward enough to make the repeated code the easier and clearer # awkward enough to make the repeated code the easier and clearer