diff options
author | Simon Howard | 2006-05-22 00:20:48 +0000 |
---|---|---|
committer | Simon Howard | 2006-05-22 00:20:48 +0000 |
commit | 283f71d0f500541b6273316120e252b03f22fb03 (patch) | |
tree | 7a46a0b56e025a70872f54b5e97d6d7773e5144e /textscreen/txt_button.c | |
parent | d90a63ed267516f8d35b4d8399dbcb5e52a1e692 (diff) | |
download | chocolate-doom-283f71d0f500541b6273316120e252b03f22fb03.tar.gz chocolate-doom-283f71d0f500541b6273316120e252b03f22fb03.tar.bz2 chocolate-doom-283f71d0f500541b6273316120e252b03f22fb03.zip |
Add a signals architecture to allow callbacks on GUI events.
Make all widget classes initialise widgets by calling TXT_InitWidget.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 501
Diffstat (limited to 'textscreen/txt_button.c')
-rw-r--r-- | textscreen/txt_button.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/textscreen/txt_button.c b/textscreen/txt_button.c index b7ae1765..e20f462d 100644 --- a/textscreen/txt_button.c +++ b/textscreen/txt_button.c @@ -1,6 +1,8 @@ #include <string.h> +#include "doomkeys.h" + #include "txt_button.h" #include "txt_io.h" #include "txt_main.h" @@ -44,11 +46,15 @@ static void TXT_ButtonDestructor(txt_widget_t *widget) txt_button_t *button = (txt_button_t *) widget; free(button->label); - free(button); } static int TXT_ButtonKeyPress(txt_widget_t *widget, int key) { + if (key == KEY_ENTER) + { + TXT_EmitSignal(widget, "pressed"); + } + return 0; } @@ -66,9 +72,7 @@ txt_button_t *TXT_NewButton(char *label) button = malloc(sizeof(txt_button_t)); - button->widget.widget_class = &txt_button_class; - button->widget.selectable = 1; - button->widget.visible = 1; + TXT_InitWidget(button, &txt_button_class); button->label = strdup(label); return button; |