summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2011-04-04 20:30:17 +0000
committerSimon Howard2011-04-04 20:30:17 +0000
commit954eeae87efa9967164ce3c0543c45b823c40a21 (patch)
treea0e0c93673774439ebce0d7cdc611eea82430669
parenteac4192d1bd74b61475ecfd3d5bee703b68ec09d (diff)
downloadchocolate-doom-954eeae87efa9967164ce3c0543c45b823c40a21.tar.gz
chocolate-doom-954eeae87efa9967164ce3c0543c45b823c40a21.tar.bz2
chocolate-doom-954eeae87efa9967164ce3c0543c45b823c40a21.zip
Close dropdown list popup windows when clicking outside the window.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2323
-rw-r--r--NEWS2
-rw-r--r--textscreen/txt_dropdown.c17
2 files changed, 19 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d37ee185..45c51e71 100644
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,8 @@
panes.
* Clicking on scroll bars now moves the scroll handle to a
matching location.
+ * Clicking outside a dropdown list popup window now dismisses the
+ window.
1.5.0 (2011-01-02):
diff --git a/textscreen/txt_dropdown.c b/textscreen/txt_dropdown.c
index 01cf830d..c9a5d015 100644
--- a/textscreen/txt_dropdown.c
+++ b/textscreen/txt_dropdown.c
@@ -99,6 +99,22 @@ static int SelectorWindowListener(txt_window_t *window, int key, void *user_data
return 0;
}
+static int SelectorMouseListener(txt_window_t *window, int x, int y, int b,
+ void *unused)
+{
+ txt_widget_t *win;
+
+ win = (txt_widget_t *) window;
+
+ if (x < win->x || x > win->x + win->w || y < win->y || y > win->y + win->h)
+ {
+ TXT_CloseWindow(window);
+ return 1;
+ }
+
+ return 0;
+}
+
// Open the dropdown list window to select an item
static void OpenSelectorWindow(txt_dropdown_list_t *list)
@@ -158,6 +174,7 @@ static void OpenSelectorWindow(txt_dropdown_list_t *list)
// Catch presses of escape in this window and close it.
TXT_SetKeyListener(window, SelectorWindowListener, NULL);
+ TXT_SetMouseListener(window, SelectorMouseListener, NULL);
}
static int DropdownListWidth(txt_dropdown_list_t *list)