From 240a1cfcca8f53a114a4302e93af793be21809d0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 23 May 2006 19:33:35 +0000 Subject: Add a default action to close windows when escape is pressed. Do not make escape quit the program unless there are no open windows. Add TXT_ExitMainLoop(). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 518 --- textscreen/txt_window.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'textscreen/txt_window.c') diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index b66995d7..9c1f0257 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -45,6 +45,13 @@ void TXT_SetWindowAction(txt_window_t *window, window->actions[position] = action; } +static void DefaultCancelAction(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window)) +{ + TXT_CAST_ARG(txt_window_t, window); + + TXT_CloseWindow(window); +} + txt_window_t *TXT_NewWindow(char *title) { int i; @@ -74,6 +81,7 @@ txt_window_t *TXT_NewWindow(char *title) cancel_action = TXT_NewWindowAction(KEY_ESCAPE, "Abort"); TXT_SetWindowAction(win, TXT_HORIZ_LEFT, cancel_action); + TXT_SignalConnect(cancel_action, "pressed", DefaultCancelAction, win); accept_action = TXT_NewWindowAction(KEY_ENTER, "Accept"); TXT_SetWindowAction(win, TXT_HORIZ_RIGHT, accept_action); -- cgit v1.2.3