summaryrefslogtreecommitdiffstats
path: root/ui/ncurses
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-07-21 13:03:28 +1000
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2016-07-21 15:39:37 +1000
commit297d2f0cc9c0a233fadf42dacc08708ad3909f77 (patch)
tree7d7f679bbd675e6e95167dbbcbfeda5fd340ecd9 /ui/ncurses
parent7e6dd06b20beda18d07ce725e4d8c4473d10d902 (diff)
downloadtalos-petitboot-297d2f0cc9c0a233fadf42dacc08708ad3909f77.tar.gz
talos-petitboot-297d2f0cc9c0a233fadf42dacc08708ad3909f77.zip
ui/ncurses: Call widget process_key handlers first
Adding KEY_LEFT and KEY_RIGHT brought to light the problem that widgetset_process_keys() may handle keystrokes that would have also been handled by a widget's process_keys function. In particular the cursor in a textbox widget could no longer be moved with the left/right keys. This updates widgetset_process_keys() to call the focussed widget's process_keys function before handling the key in any other way. All of the widget process_keys functions correctly return false if the key is not relevant to the widget except for textbox_process_key() which is updated to ignore the main navigational keys. Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'ui/ncurses')
-rw-r--r--ui/ncurses/nc-widgets.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/ui/ncurses/nc-widgets.c b/ui/ncurses/nc-widgets.c
index 8f8816e..7dc2df3 100644
--- a/ui/ncurses/nc-widgets.c
+++ b/ui/ncurses/nc-widgets.c
@@ -337,6 +337,14 @@ static bool textbox_process_key(
case KEY_DC:
form_driver(form, REQ_DEL_CHAR);
break;
+ case '\t':
+ case KEY_BTAB:
+ case KEY_UP:
+ case KEY_DOWN:
+ case KEY_PPAGE:
+ case KEY_NPAGE:
+ /* Don't catch navigational keys */
+ return false;
default:
form_driver(form, key);
break;
@@ -1110,6 +1118,12 @@ bool widgetset_process_key(struct nc_widgetset *set, int key)
field = current_field(set->form);
assert(field);
+ widget = field_userptr(field);
+
+ if (widget->process_key)
+ if (widget->process_key(widget, set->form, key))
+ return true;
+
tab = false;
/* handle field change events */
@@ -1136,7 +1150,6 @@ bool widgetset_process_key(struct nc_widgetset *set, int key)
break;
}
- widget = field_userptr(field);
if (req) {
widget_focus_change(widget, field, false);
form_driver(set->form, req);
@@ -1161,10 +1174,7 @@ bool widgetset_process_key(struct nc_widgetset *set, int key)
return true;
}
- if (!widget->process_key)
- return false;
-
- return widget->process_key(widget, set->form, key);
+ return false;
}
static int widgetset_destructor(void *ptr)
OpenPOWER on IntegriCloud