From 62b5f953677addeebac38ab6774599bbbab130f0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 20 May 2006 16:34:34 +0000 Subject: Add main loop function and forward key presses to widgets. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 490 --- textscreen/txt_window.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'textscreen/txt_window.c') 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 #include +#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; + } + } + } +} + -- cgit v1.2.3