summaryrefslogtreecommitdiff
path: root/src/ui/util.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-09-16 07:01:40 +0300
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-09-16 07:01:40 +0300
commit56b80c25a8512be27669b0e99ac61b07d276df2e (patch)
treec09d2d157495ce5972ec649747a3d24ba1db1c67 /src/ui/util.c
parent5293de3a437b10656e4e678cffecdc1cf416b9d9 (diff)
Dismiss menus when clicking outside them
Added a new widget flag for notifying about missed mouse clicks. Only used in popup menus at the moment. IssueID #2
Diffstat (limited to 'src/ui/util.c')
-rw-r--r--src/ui/util.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 0af33138..e055244b 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -201,7 +201,8 @@ static iBool menuHandler_(iWidget *menu, const char *cmd) {
201 /* Don't reopen self; instead, root will close the menu. */ 201 /* Don't reopen self; instead, root will close the menu. */
202 return iFalse; 202 return iFalse;
203 } 203 }
204 if (equal_Command(cmd, "mouse.clicked") && arg_Command(cmd)) { 204 if ((equal_Command(cmd, "mouse.clicked") || equal_Command(cmd, "mouse.missed")) &&
205 arg_Command(cmd)) {
205 /* Dismiss open menus when clicking outside them. */ 206 /* Dismiss open menus when clicking outside them. */
206 closeMenu_Widget(menu); 207 closeMenu_Widget(menu);
207 return iTrue; 208 return iTrue;
@@ -252,6 +253,7 @@ void openMenu_Widget(iWidget *d, iInt2 coord) {
252 postCommand_App("cancel"); /* dismiss any other menus */ 253 postCommand_App("cancel"); /* dismiss any other menus */
253 processEvents_App(postedEventsOnly_AppEventMode); 254 processEvents_App(postedEventsOnly_AppEventMode);
254 setFlags_Widget(d, hidden_WidgetFlag, iFalse); 255 setFlags_Widget(d, hidden_WidgetFlag, iFalse);
256 setFlags_Widget(d, commandOnMouseMiss_WidgetFlag, iTrue);
255 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse); 257 setFlags_Widget(findChild_Widget(d, "menu.cancel"), disabled_WidgetFlag, iFalse);
256 arrange_Widget(d); 258 arrange_Widget(d);
257 d->rect.pos = coord; 259 d->rect.pos = coord;