From 5e303c43dab6c433bc3b59dd34d4672317c5f4e1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 31 Aug 2006 18:11:26 +0000 Subject: Add window listener functions to allow spying on keys and mouse buttons received by windows. Emit a 'closed' signal when a window is closed. Allow windows to have no action buttons. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 576 --- textscreen/txt_window.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'textscreen/txt_window.h') diff --git a/textscreen/txt_window.h b/textscreen/txt_window.h index 5e01a16d..a71307ae 100644 --- a/textscreen/txt_window.h +++ b/textscreen/txt_window.h @@ -31,6 +31,13 @@ typedef struct txt_window_s txt_window_t; #include "txt_table.h" #include "txt_window_action.h" +// Callback function for window key presses + +typedef int (*TxtWindowKeyPress)(txt_window_t *window, int key, void *user_data); +typedef int (*TxtWindowMousePress)(txt_window_t *window, + int x, int y, int b, + void *user_data); + struct txt_window_s { // Base class: all windows are tables with one column. @@ -51,6 +58,13 @@ struct txt_window_s txt_window_action_t *actions[3]; + // Callback functions to invoke when keys/mouse buttons are pressed + + TxtWindowKeyPress key_listener; + void *key_listener_data; + TxtWindowMousePress mouse_listener; + void *mouse_listener_data; + // These are set automatically when the window is drawn int window_x, window_y; @@ -65,6 +79,12 @@ void TXT_SetWindowPosition(txt_window_t *window, int x, int y); void TXT_SetWindowAction(txt_window_t *window, txt_horiz_align_t position, txt_window_action_t *action); +void TXT_SetKeyListener(txt_window_t *window, + TxtWindowKeyPress key_listener, + void *user_data); +void TXT_SetMouseListener(txt_window_t *window, + TxtWindowMousePress mouse_listener, + void *user_data); #endif /* #ifndef TXT_WINDOW_T */ -- cgit v1.2.3