From 7e393a4fda482d01252bd1a6e84ca8149bcc278e Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Sun, 17 Jan 2021 18:43:20 +0200 Subject: Improved menu button behavior Clicking a menu button while the menu is open should just close the menu. Menus should not close if the mouse pointer leaves the window. --- src/ui/widget.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/ui/widget.c') 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) { return iInvalidPos; } +iAny *hitChild_Widget(const iWidget *d, iInt2 coord) { + iConstForEach(ObjectList, i, d->children) { + iAny *found = hitChild_Widget(constAs_Widget(i.object), coord); + if (found) return found; + } + if (contains_Widget(d, coord)) { + return iConstCast(iWidget *, d); + } + return NULL; +} + iAny *findChild_Widget(const iWidget *d, const char *id) { if (cmp_String(id_Widget(d), id) == 0) { return iConstCast(iAny *, d); -- cgit v1.2.3