diff options
Diffstat (limited to 'textscreen/txt_window.c')
-rw-r--r-- | textscreen/txt_window.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index 1dcb2d88..85c6c5d1 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -25,6 +25,8 @@ #include <stdlib.h> #include <string.h> +#include "doomkeys.h" + #include "txt_desktop.h" #include "txt_gui.h" #include "txt_main.h" @@ -217,3 +219,54 @@ void TXT_SetWindowPosition(txt_window_t *window, window->y = y; } +void TXT_WindowKeyPress(txt_window_t *window, int c) +{ + // Send to the currently selected widget first + + if (window->selected > 0 && window->selected <= window->num_widgets) + { + if (TXT_WidgetKeyPress(window->widgets[window->selected], c)) + { + return; + } + } + + if (c == KEY_DOWNARROW) + { + int newsel; + + // Move cursor down to the next selectable widget + + for (newsel = window->selected + 1; + newsel < window->num_widgets; + ++newsel) + { + if (window->widgets[newsel]->visible + && window->widgets[newsel]->selectable) + { + window->selected = newsel; + break; + } + } + } + + if (c == KEY_UPARROW) + { + int newsel; + + // Move cursor down to the next selectable widget + + for (newsel = window->selected - 1; + newsel >= 0; + --newsel) + { + if (window->widgets[newsel]->visible + && window->widgets[newsel]->selectable) + { + window->selected = newsel; + break; + } + } + } +} + |