summaryrefslogtreecommitdiff
path: root/src/ui/inputwidget.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/inputwidget.c')
-rw-r--r--src/ui/inputwidget.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ui/inputwidget.c b/src/ui/inputwidget.c
index e51ec64b..25c3e145 100644
--- a/src/ui/inputwidget.c
+++ b/src/ui/inputwidget.c
@@ -346,10 +346,13 @@ static void insertChar_InputWidget_(iInputWidget *d, iChar chr) {
346 resize_Array(&d->text, d->cursor + 1); 346 resize_Array(&d->text, d->cursor + 1);
347 } 347 }
348 set_Array(&d->text, d->cursor++, &chr); 348 set_Array(&d->text, d->cursor++, &chr);
349 if (d->maxLen && d->cursor == d->maxLen) { 349 if (d->maxLen > 1 && d->cursor == d->maxLen) {
350 iWidget *nextFocus = findFocusable_Widget(w, forward_WidgetFocusDir); 350 iWidget *nextFocus = findFocusable_Widget(w, forward_WidgetFocusDir);
351 setFocus_Widget(nextFocus == w ? NULL : nextFocus); 351 setFocus_Widget(nextFocus == w ? NULL : nextFocus);
352 } 352 }
353 else if (d->maxLen == 1) {
354 d->cursor = 0;
355 }
353 } 356 }
354 showCursor_InputWidget_(d); 357 showCursor_InputWidget_(d);
355 refresh_Widget(as_Widget(d)); 358 refresh_Widget(as_Widget(d));
@@ -675,6 +678,11 @@ static iBool processEvent_InputWidget_(iInputWidget *d, const SDL_Event *ev) {
675 remove_Array(&d->text, --d->cursor); 678 remove_Array(&d->text, --d->cursor);
676 contentsWereChanged_InputWidget_(d); 679 contentsWereChanged_InputWidget_(d);
677 } 680 }
681 else if (d->cursor == 0 && d->maxLen == 1) {
682 pushUndo_InputWidget_(d);
683 clear_Array(&d->text);
684 contentsWereChanged_InputWidget_(d);
685 }
678 showCursor_InputWidget_(d); 686 showCursor_InputWidget_(d);
679 refresh_Widget(w); 687 refresh_Widget(w);
680 return iTrue; 688 return iTrue;