summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-02 14:17:00 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-02 14:17:00 +0200
commit6d885dee5e3a9fc7316c901542eec21e39ae1f12 (patch)
tree2b8a2acb393329317e975d4294f28a5a34967d9a /src/ui/inputwidget.c
parentec82863a833d3533381dddbb170a8505a24e159d (diff)
Improved focus switching for dialogs
Widgets can now be defined as being the "focus root", i.e., the topmost widget under which focus switching happens. Normally this is the window root widget, but dialogs use this flag to confine focus switching inside the dialog. InputWidget in Overwrite mode will focus switch to the next focusable widget when the text field becomes full.
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index ae73c9c9..3f799e3c 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -331,6 +331,7 @@ void end_InputWidget(iInputWidget *d, iBool accept) {
331} 331}
332 332
333static void insertChar_InputWidget_(iInputWidget *d, iChar chr) { 333static void insertChar_InputWidget_(iInputWidget *d, iChar chr) {
334 iWidget *w = as_Widget(d);
334 if (d->mode == insert_InputMode) { 335 if (d->mode == insert_InputMode) {
335 insert_Array(&d->text, d->cursor, &chr); 336 insert_Array(&d->text, d->cursor, &chr);
336 d->cursor++; 337 d->cursor++;
@@ -341,7 +342,8 @@ static void insertChar_InputWidget_(iInputWidget *d, iChar chr) {
341 } 342 }
342 set_Array(&d->text, d->cursor++, &chr); 343 set_Array(&d->text, d->cursor++, &chr);
343 if (d->maxLen && d->cursor == d->maxLen) { 344 if (d->maxLen && d->cursor == d->maxLen) {
344 setFocus_Widget(NULL); 345 iWidget *nextFocus = findFocusable_Widget(w, forward_WidgetFocusDir);
346 setFocus_Widget(nextFocus == w ? NULL : nextFocus);
345 } 347 }
346 } 348 }
347 showCursor_InputWidget_(d); 349 showCursor_InputWidget_(d);