From dd52766c7be893a6a5db31bc396ccef8d758af45 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 23 Oct 2011 19:25:55 +0000 Subject: 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 --- textscreen/txt_desktop.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'textscreen/txt_desktop.c') diff --git a/textscreen/txt_desktop.c b/textscreen/txt_desktop.c index c497f0e3..2c7caa27 100644 --- a/textscreen/txt_desktop.c +++ b/textscreen/txt_desktop.c @@ -41,14 +41,29 @@ static int main_loop_running = 0; void TXT_AddDesktopWindow(txt_window_t *win) { + // Previously-top window loses focus: + + if (num_windows > 0) + { + TXT_SetWindowFocus(all_windows[num_windows - 1], 0); + } + all_windows[num_windows] = win; ++num_windows; + + // New window gains focus: + + TXT_SetWindowFocus(win, 1); } void TXT_RemoveDesktopWindow(txt_window_t *win) { int from, to; + // Window must lose focus if it's being removed: + + TXT_SetWindowFocus(win, 0); + for (from=0, to=0; from 0) + { + TXT_SetWindowFocus(all_windows[num_windows - 1], 1); + } } txt_window_t *TXT_GetActiveWindow(void) @@ -140,7 +162,7 @@ void TXT_DrawDesktop(void) for (i=0; i