summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/util.c4
-rw-r--r--src/ui/widget.c9
-rw-r--r--src/ui/widget.h1
3 files changed, 13 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;
diff --git a/src/ui/widget.c b/src/ui/widget.c
index d3f28b08..05bb62cc 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -542,6 +542,15 @@ iBool processEvent_Widget(iWidget *d, const SDL_Event *ev) {
542 break; 542 break;
543 } 543 }
544 } 544 }
545 if (d->flags & commandOnMouseMiss_WidgetFlag && ev->type == SDL_MOUSEBUTTONDOWN &&
546 !contains_Widget(d, init_I2(ev->button.x, ev->button.y))) {
547 postCommand_Widget(d,
548 "mouse.missed arg:%d button:%d coord:%d %d",
549 ev->type == SDL_MOUSEBUTTONDOWN ? 1 : 0,
550 ev->button.button,
551 ev->button.x,
552 ev->button.y);
553 }
545 if (d->flags & mouseModal_WidgetFlag && isMouseEvent_(ev)) { 554 if (d->flags & mouseModal_WidgetFlag && isMouseEvent_(ev)) {
546 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW); 555 setCursor_Window(get_Window(), SDL_SYSTEM_CURSOR_ARROW);
547 return iTrue; 556 return iTrue;
diff --git a/src/ui/widget.h b/src/ui/widget.h
index 25208c30..fa4fbe0f 100644
--- a/src/ui/widget.h
+++ b/src/ui/widget.h
@@ -58,6 +58,7 @@ enum iWidgetFlag {
58 tight_WidgetFlag = iBit(12), /* smaller padding */ 58 tight_WidgetFlag = iBit(12), /* smaller padding */
59 keepOnTop_WidgetFlag = iBit(13), /* gets events first; drawn last */ 59 keepOnTop_WidgetFlag = iBit(13), /* gets events first; drawn last */
60 mouseModal_WidgetFlag = iBit(14), /* eats all unprocessed mouse events */ 60 mouseModal_WidgetFlag = iBit(14), /* eats all unprocessed mouse events */
61 commandOnMouseMiss_WidgetFlag = iBit(15),
61 /* arrange behavior */ 62 /* arrange behavior */
62 fixedPosition_WidgetFlag = iBit(16), 63 fixedPosition_WidgetFlag = iBit(16),
63 arrangeHorizontal_WidgetFlag = iBit(17), /* arrange children horizontally */ 64 arrangeHorizontal_WidgetFlag = iBit(17), /* arrange children horizontally */