From b81e34b2361d85257bfbbe8bde74fff7064bac96 Mon Sep 17 00:00:00 2001 From: and3md Date: Sun, 18 Feb 2018 15:54:38 +0100 Subject: [PATCH] Closing the popupMenu by clicking outside, should not pass the event to the control under the mouse. --- src/dlangui/platforms/common/platform.d | 7 +++++-- src/dlangui/widgets/popup.d | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index 2d754884..87909009 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -1505,8 +1505,11 @@ class Window : CustomEventTarget { if (p is modal) break; if (!insideOneOfPopups) { - if (p.onMouseEventOutside(event)) // stop loop when true is returned, but allow other main widget to handle event - break; + if (event.action == MouseAction.ButtonDown) + return true; // mouse button down should do nothing when click outside when popup visible + if (p.onMouseEventOutside(event)) { + return true; // mouse button up should do nothing when click outside when popup visible + } } else { if (dispatchMouseEvent(p, event, cursorIsSet)) return true; diff --git a/src/dlangui/widgets/popup.d b/src/dlangui/widgets/popup.d index 21ca8956..b4cfc352 100644 --- a/src/dlangui/widgets/popup.d +++ b/src/dlangui/widgets/popup.d @@ -174,10 +174,10 @@ class PopupWidget : LinearLayout { if (visibility != Visibility.Visible) return false; if (_flags & PopupFlags.CloseOnClickOutside) { - if (event.action == MouseAction.ButtonDown) { + if (event.action == MouseAction.ButtonUp) { // clicked outside - close popup close(); - return false; + return true; } } if (_flags & PopupFlags.CloseOnMouseMoveOutside) {