diff options
Diffstat (limited to 'textscreen/txt_window.h')
-rw-r--r-- | textscreen/txt_window.h | 20 |
1 files changed, 20 insertions, 0 deletions
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 */ |