From 48d2fd26ca4c1de5112103788841751619ebfe9c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 2 Jun 2006 20:50:51 +0000 Subject: Make clicking on "accept" action buttons send enter keypresses to the window. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 554 --- textscreen/txt_window.c | 2 +- textscreen/txt_window_action.c | 16 ++++++++++++++-- textscreen/txt_window_action.h | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/textscreen/txt_window.c b/textscreen/txt_window.c index 7481ccfa..5da2e008 100644 --- a/textscreen/txt_window.c +++ b/textscreen/txt_window.c @@ -73,7 +73,7 @@ txt_window_t *TXT_NewWindow(char *title) // Default actions TXT_SetWindowAction(win, TXT_HORIZ_LEFT, TXT_NewWindowEscapeAction(win)); - TXT_SetWindowAction(win, TXT_HORIZ_RIGHT, TXT_NewWindowAcceptAction()); + TXT_SetWindowAction(win, TXT_HORIZ_RIGHT, TXT_NewWindowAcceptAction(win)); return win; } diff --git a/textscreen/txt_window_action.c b/textscreen/txt_window_action.c index a70d0002..aabae15b 100644 --- a/textscreen/txt_window_action.c +++ b/textscreen/txt_window_action.c @@ -100,6 +100,13 @@ static void WindowCloseCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window)) TXT_CloseWindow(window); } +static void WindowAcceptCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(window)) +{ + TXT_CAST_ARG(txt_window_t, window); + + TXT_WidgetKeyPress(window, KEY_ENTER); +} + txt_window_action_t *TXT_NewWindowEscapeAction(txt_window_t *window) { txt_window_action_t *action; @@ -110,8 +117,13 @@ txt_window_action_t *TXT_NewWindowEscapeAction(txt_window_t *window) return action; } -txt_window_action_t *TXT_NewWindowAcceptAction(void) +txt_window_action_t *TXT_NewWindowAcceptAction(txt_window_t *window) { - return TXT_NewWindowAction(KEY_ENTER, "Accept"); + txt_window_action_t *action; + + action = TXT_NewWindowAction(KEY_ENTER, "Accept"); + TXT_SignalConnect(action, "pressed", WindowAcceptCallback, window); + + return action; } diff --git a/textscreen/txt_window_action.h b/textscreen/txt_window_action.h index 2310547f..80e1d3e5 100644 --- a/textscreen/txt_window_action.h +++ b/textscreen/txt_window_action.h @@ -45,7 +45,7 @@ txt_window_action_t *TXT_NewWindowEscapeAction(txt_window_t *window); // Accept button that does nothing -txt_window_action_t *TXT_NewWindowAcceptAction(void); +txt_window_action_t *TXT_NewWindowAcceptAction(txt_window_t *window); #endif /* #ifndef TXT_WINDOW_ACTION_H */ -- cgit v1.2.3