diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/inputwidget.c | 4 | ||||
-rw-r--r-- | src/ui/util.c | 6 | ||||
-rw-r--r-- | src/ui/widget.c | 16 | ||||
-rw-r--r-- | src/ui/widget.h | 1 | ||||
-rw-r--r-- | src/ui/window.c | 1 |
5 files changed, 23 insertions, 5 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 | ||
333 | static void insertChar_InputWidget_(iInputWidget *d, iChar chr) { | 333 | static 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); |
diff --git a/src/ui/util.c b/src/ui/util.c index 91945db8..4d5ed916 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -764,9 +764,9 @@ iWidget *makeSheet_Widget(const char *id) { | |||
764 | setFrameColor_Widget(sheet, uiSeparator_ColorId); | 764 | setFrameColor_Widget(sheet, uiSeparator_ColorId); |
765 | setBackgroundColor_Widget(sheet, uiBackground_ColorId); | 765 | setBackgroundColor_Widget(sheet, uiBackground_ColorId); |
766 | setFlags_Widget(sheet, | 766 | setFlags_Widget(sheet, |
767 | mouseModal_WidgetFlag | keepOnTop_WidgetFlag | arrangeVertical_WidgetFlag | | 767 | focusRoot_WidgetFlag | mouseModal_WidgetFlag | keepOnTop_WidgetFlag | |
768 | arrangeSize_WidgetFlag | centerHorizontal_WidgetFlag | | 768 | arrangeVertical_WidgetFlag | arrangeSize_WidgetFlag | |
769 | overflowScrollable_WidgetFlag, | 769 | centerHorizontal_WidgetFlag | overflowScrollable_WidgetFlag, |
770 | iTrue); | 770 | iTrue); |
771 | return sheet; | 771 | return sheet; |
772 | } | 772 | } |
diff --git a/src/ui/widget.c b/src/ui/widget.c index e2d0f922..ddb3f092 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -877,8 +877,22 @@ static const iWidget *findFocusable_Widget_(const iWidget *d, const iWidget *sta | |||
877 | return NULL; | 877 | return NULL; |
878 | } | 878 | } |
879 | 879 | ||
880 | static const iWidget *findFocusRoot_Widget_(const iWidget *d) { | ||
881 | iForEach(ObjectList, i, d->children) { | ||
882 | const iWidget *root = findFocusRoot_Widget_(constAs_Widget(i.object)); | ||
883 | if (root) { | ||
884 | return root; | ||
885 | } | ||
886 | } | ||
887 | if (d->flags & focusRoot_WidgetFlag) { | ||
888 | return d; | ||
889 | } | ||
890 | return NULL; | ||
891 | } | ||
892 | |||
880 | iAny *findFocusable_Widget(const iWidget *startFrom, enum iWidgetFocusDir focusDir) { | 893 | iAny *findFocusable_Widget(const iWidget *startFrom, enum iWidgetFocusDir focusDir) { |
881 | iWidget *root = get_Window()->root; | 894 | const iWidget *root = findFocusRoot_Widget_(get_Window()->root); |
895 | iAssert(root != NULL); | ||
882 | iBool getNext = (startFrom ? iFalse : iTrue); | 896 | iBool getNext = (startFrom ? iFalse : iTrue); |
883 | const iWidget *found = findFocusable_Widget_(root, startFrom, &getNext, focusDir); | 897 | const iWidget *found = findFocusable_Widget_(root, startFrom, &getNext, focusDir); |
884 | if (!found && startFrom) { | 898 | if (!found && startFrom) { |
diff --git a/src/ui/widget.h b/src/ui/widget.h index e40b333b..79f68b3c 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h | |||
@@ -90,6 +90,7 @@ enum iWidgetFlag { | |||
90 | #define wrapText_WidgetFlag iBit64(36) | 90 | #define wrapText_WidgetFlag iBit64(36) |
91 | #define borderTop_WidgetFlag iBit64(37) | 91 | #define borderTop_WidgetFlag iBit64(37) |
92 | #define overflowScrollable_WidgetFlag iBit64(38) | 92 | #define overflowScrollable_WidgetFlag iBit64(38) |
93 | #define focusRoot_WidgetFlag iBit64(39) | ||
93 | 94 | ||
94 | enum iWidgetAddPos { | 95 | enum iWidgetAddPos { |
95 | back_WidgetAddPos, | 96 | back_WidgetAddPos, |
diff --git a/src/ui/window.c b/src/ui/window.c index 66994e79..8df92706 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -781,6 +781,7 @@ void init_Window(iWindow *d, iRect rect) { | |||
781 | } | 781 | } |
782 | #endif | 782 | #endif |
783 | d->root = new_Widget(); | 783 | d->root = new_Widget(); |
784 | setFlags_Widget(d->root, focusRoot_WidgetFlag, iTrue); | ||
784 | d->presentTime = 0.0; | 785 | d->presentTime = 0.0; |
785 | d->frameTime = SDL_GetTicks(); | 786 | d->frameTime = SDL_GetTicks(); |
786 | d->loadAnimTimer = 0; | 787 | d->loadAnimTimer = 0; |