diff options
author | Simon Howard | 2011-10-23 19:25:55 +0000 |
---|---|---|
committer | Simon Howard | 2011-10-23 19:25:55 +0000 |
commit | dd52766c7be893a6a5db31bc396ccef8d758af45 (patch) | |
tree | 0ece2688a18f5f8f3d893047973d1c6ab4c82df1 /textscreen/txt_window.c | |
parent | 71d316afb2ae7191a4ef6fac2d757238ae3616e1 (diff) | |
download | chocolate-doom-dd52766c7be893a6a5db31bc396ccef8d758af45.tar.gz chocolate-doom-dd52766c7be893a6a5db31bc396ccef8d758af45.tar.bz2 chocolate-doom-dd52766c7be893a6a5db31bc396ccef8d758af45.zip |
Rework textscreen focus handling so that input boxes will stop editing
when they lose their focus (thanks Twelve).
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2460
Diffstat (limited to 'textscreen/txt_window.c')
-rw-r--r-- | textscreen/txt_window.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index cd8a6c7a..62f3ac8a 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -216,7 +216,7 @@ static void DrawActionArea(txt_window_t *window) { if (window->actions[i] != NULL) { - TXT_DrawWidget(window->actions[i], 0); + TXT_DrawWidget(window->actions[i]); } } } @@ -315,7 +315,7 @@ void TXT_LayoutWindow(txt_window_t *window) TXT_LayoutWidget(widgets); } -void TXT_DrawWindow(txt_window_t *window, int selected) +void TXT_DrawWindow(txt_window_t *window) { txt_widget_t *widgets; @@ -329,7 +329,7 @@ void TXT_DrawWindow(txt_window_t *window, int selected) // Draw all widgets - TXT_DrawWidget(window, selected); + TXT_DrawWidget(window); // Draw an action area, if we have one @@ -408,7 +408,21 @@ static void MouseButtonPress(txt_window_t *window, int b) && x >= widget->x && x < (signed) (widget->x + widget->w) && y >= widget->y && y < (signed) (widget->y + widget->h)) { + int was_focused; + + // Main table temporarily loses focus when action area button + // is clicked. This way, any active input boxes that depend + // on having focus will save their values before the + // action is performed. + + was_focused = window->table.widget.focused; + TXT_SetWidgetFocus(window, 0); + TXT_SetWidgetFocus(window, was_focused); + + // Pass through mouse press. + TXT_WidgetMousePress(widget, x, y, b); + break; } } @@ -472,3 +486,8 @@ void TXT_SetMouseListener(txt_window_t *window, window->mouse_listener_data = user_data; } +void TXT_SetWindowFocus(txt_window_t *window, int focused) +{ + TXT_SetWidgetFocus(window, focused); +} + |