diff options
-rw-r--r-- | src/ui/util.c | 15 | ||||
-rw-r--r-- | src/ui/widget.c | 11 | ||||
-rw-r--r-- | src/ui/widget.h | 1 |
3 files changed, 27 insertions, 0 deletions
diff --git a/src/ui/util.c b/src/ui/util.c index 222d5716..7fc27130 100644 --- a/src/ui/util.c +++ b/src/ui/util.c | |||
@@ -380,9 +380,21 @@ static iBool isCommandIgnoredByMenus_(const char *cmd) { | |||
380 | equal_Command(cmd, "bookmarks.request.finished") || | 380 | equal_Command(cmd, "bookmarks.request.finished") || |
381 | equal_Command(cmd, "window.resized") || | 381 | equal_Command(cmd, "window.resized") || |
382 | equal_Command(cmd, "window.reload.update") || | 382 | equal_Command(cmd, "window.reload.update") || |
383 | equal_Command(cmd, "window.mouse.exited") || | ||
384 | equal_Command(cmd, "window.mouse.entered") || | ||
383 | (equal_Command(cmd, "mouse.clicked") && !arg_Command(cmd)); /* button released */ | 385 | (equal_Command(cmd, "mouse.clicked") && !arg_Command(cmd)); /* button released */ |
384 | } | 386 | } |
385 | 387 | ||
388 | static iLabelWidget *parentMenuButton_(const iWidget *menu) { | ||
389 | if (isInstance_Object(menu->parent, &Class_LabelWidget)) { | ||
390 | iLabelWidget *button = (iLabelWidget *) menu->parent; | ||
391 | if (!cmp_String(command_LabelWidget(button), "menu.open")) { | ||
392 | return button; | ||
393 | } | ||
394 | } | ||
395 | return NULL; | ||
396 | } | ||
397 | |||
386 | static iBool menuHandler_(iWidget *menu, const char *cmd) { | 398 | static iBool menuHandler_(iWidget *menu, const char *cmd) { |
387 | if (isVisible_Widget(menu)) { | 399 | if (isVisible_Widget(menu)) { |
388 | if (equalWidget_Command(cmd, menu, "menu.opened")) { | 400 | if (equalWidget_Command(cmd, menu, "menu.opened")) { |
@@ -394,6 +406,9 @@ static iBool menuHandler_(iWidget *menu, const char *cmd) { | |||
394 | } | 406 | } |
395 | if ((equal_Command(cmd, "mouse.clicked") || equal_Command(cmd, "mouse.missed")) && | 407 | if ((equal_Command(cmd, "mouse.clicked") || equal_Command(cmd, "mouse.missed")) && |
396 | arg_Command(cmd)) { | 408 | arg_Command(cmd)) { |
409 | if (hitChild_Widget(get_Window()->root, coord_Command(cmd)) == parentMenuButton_(menu)) { | ||
410 | return iFalse; | ||
411 | } | ||
397 | /* Dismiss open menus when clicking outside them. */ | 412 | /* Dismiss open menus when clicking outside them. */ |
398 | closeMenu_Widget(menu); | 413 | closeMenu_Widget(menu); |
399 | return iTrue; | 414 | return iTrue; |
diff --git a/src/ui/widget.c b/src/ui/widget.c index f3e73ee7..1d2aecf0 100644 --- a/src/ui/widget.c +++ b/src/ui/widget.c | |||
@@ -728,6 +728,17 @@ size_t childIndex_Widget(const iWidget *d, const iAnyObject *child) { | |||
728 | return iInvalidPos; | 728 | return iInvalidPos; |
729 | } | 729 | } |
730 | 730 | ||
731 | iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { | ||
732 | iConstForEach(ObjectList, i, d->children) { | ||
733 | iAny *found = hitChild_Widget(constAs_Widget(i.object), coord); | ||
734 | if (found) return found; | ||
735 | } | ||
736 | if (contains_Widget(d, coord)) { | ||
737 | return iConstCast(iWidget *, d); | ||
738 | } | ||
739 | return NULL; | ||
740 | } | ||
741 | |||
731 | iAny *findChild_Widget(const iWidget *d, const char *id) { | 742 | iAny *findChild_Widget(const iWidget *d, const char *id) { |
732 | if (cmp_String(id_Widget(d), id) == 0) { | 743 | if (cmp_String(id_Widget(d), id) == 0) { |
733 | return iConstCast(iAny *, d); | 744 | return iConstCast(iAny *, d); |
diff --git a/src/ui/widget.h b/src/ui/widget.h index f06a6607..e40b333b 100644 --- a/src/ui/widget.h +++ b/src/ui/widget.h | |||
@@ -146,6 +146,7 @@ iRect bounds_Widget (const iWidget *); /* outer bounds */ | |||
146 | iRect innerBounds_Widget (const iWidget *); | 146 | iRect innerBounds_Widget (const iWidget *); |
147 | iInt2 localCoord_Widget (const iWidget *, iInt2 coord); | 147 | iInt2 localCoord_Widget (const iWidget *, iInt2 coord); |
148 | iBool contains_Widget (const iWidget *, iInt2 coord); | 148 | iBool contains_Widget (const iWidget *, iInt2 coord); |
149 | iAny * hitChild_Widget (const iWidget *, iInt2 coord); | ||
149 | iAny * findChild_Widget (const iWidget *, const char *id); | 150 | iAny * findChild_Widget (const iWidget *, const char *id); |
150 | iAny * findParentClass_Widget(const iWidget *, const iAnyClass *class); | 151 | iAny * findParentClass_Widget(const iWidget *, const iAnyClass *class); |
151 | iAny * findFocusable_Widget(const iWidget *startFrom, enum iWidgetFocusDir focusDir); | 152 | iAny * findFocusable_Widget(const iWidget *startFrom, enum iWidgetFocusDir focusDir); |