Keyboard navigation for fields

This commit is contained in:
Mark Qvist 2023-02-15 11:53:34 +01:00
parent 1a84e0c019
commit e266719e2c
2 changed files with 19 additions and 4 deletions

View file

@ -31,6 +31,12 @@ You can `!`[submit`:/page/input_fields.mu`one|password|small]`! other fields, or
Or simply `!`[submit them all`:/page/input_fields.mu`*]`!. Or simply `!`[submit them all`:/page/input_fields.mu`*]`!.
Submission links can also `!`[include pre-configured variables`:/page/input_fields.mu`username|two|entitiy_id=4611|action=view]`!.
Or take all fields and `!`[pre-configured variables`:/page/input_fields.mu`*|entitiy_id=4611|action=view]`!.
Or only `!`[pre-configured variables`:/page/input_fields.mu`entitiy_id=4688|task=something]`!
-= -=
""" """

View file

@ -158,6 +158,7 @@ def parse_line(line, state, url_delegate):
if isinstance(o, tuple): if isinstance(o, tuple):
if url_delegate != None: if url_delegate != None:
tw = LinkableText(o, align=state["align"], delegate=url_delegate) tw = LinkableText(o, align=state["align"], delegate=url_delegate)
tw.in_columns = True
else: else:
tw = urwid.Text(o, align=state["align"]) tw = urwid.Text(o, align=state["align"])
@ -621,6 +622,7 @@ class LinkableText(urwid.Text):
self.delegate = delegate self.delegate = delegate
self._cursor_position = 0 self._cursor_position = 0
self.key_timeout = 3 self.key_timeout = 3
self.in_columns = False
if self.delegate != None: if self.delegate != None:
self.delegate.last_keypress = 0 self.delegate.last_keypress = 0
@ -697,7 +699,11 @@ class LinkableText(urwid.Text):
elif key == "right": elif key == "right":
old = self._cursor_position old = self._cursor_position
self._cursor_position = self.find_next_part_pos(self._cursor_position, part_positions) self._cursor_position = self.find_next_part_pos(self._cursor_position, part_positions)
if self._cursor_position == old: if self._cursor_position == old:
if self.in_columns:
return "right"
else:
self._cursor_position = 0 self._cursor_position = 0
return "down" return "down"
@ -705,6 +711,9 @@ class LinkableText(urwid.Text):
elif key == "left": elif key == "left":
if self._cursor_position > 0: if self._cursor_position > 0:
if self.in_columns:
return "left"
else:
self._cursor_position = self.find_prev_part_pos(self._cursor_position, part_positions) self._cursor_position = self.find_prev_part_pos(self._cursor_position, part_positions)
self._invalidate() self._invalidate()