From ef92ce016e328c1270597f2f1627c72bc3490d64 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 2 Jun 2006 20:14:39 +0000 Subject: Make mouse button presses on widgets actually do useful things Subversion-branch: /trunk/chocolate-doom Subversion-revision: 553 --- textscreen/txt_inputbox.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'textscreen/txt_inputbox.c') diff --git a/textscreen/txt_inputbox.c b/textscreen/txt_inputbox.c index cb7bf4fa..59d62da3 100644 --- a/textscreen/txt_inputbox.c +++ b/textscreen/txt_inputbox.c @@ -188,12 +188,31 @@ static int TXT_IntInputBoxKeyPress(TXT_UNCAST_ARG(inputbox), int key) return 1; } +static void TXT_InputBoxMousePress(TXT_UNCAST_ARG(inputbox), + int x, int y, int b) +{ + TXT_CAST_ARG(txt_inputbox_t, inputbox); + + if (b == TXT_MOUSE_LEFT) + { + // Make mouse clicks start editing the box + + if (!inputbox->editing) + { + // Send a simulated keypress to start editing + + TXT_WidgetKeyPress(inputbox, KEY_ENTER); + } + } +} + txt_widget_class_t txt_inputbox_class = { TXT_InputBoxSizeCalc, TXT_InputBoxDrawer, TXT_InputBoxKeyPress, TXT_InputBoxDestructor, + TXT_InputBoxMousePress, }; txt_widget_class_t txt_int_inputbox_class = @@ -202,6 +221,7 @@ txt_widget_class_t txt_int_inputbox_class = TXT_InputBoxDrawer, TXT_IntInputBoxKeyPress, TXT_InputBoxDestructor, + TXT_InputBoxMousePress, }; static void SetBufferFromValue(txt_inputbox_t *inputbox) -- cgit v1.2.3