From 293114199de55fd66726c5945f90bf6481538d51 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Thu, 9 Mar 2023 19:46:00 +0100 Subject: [PATCH] It is standard behavior on Windows and Linux that a popup window closes, when outside of its area is clicked. I guess on Mac OS it is the same. I changed the code so the problem is solved. --- src/screen.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/screen.cpp b/src/screen.cpp index 4b04e75c..a96abf76 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -772,6 +773,27 @@ void Screen::mouse_button_callback_event(int button, int action, int modifiers) button = GLFW_MOUSE_BUTTON_2; #endif + // close any popup window, if clicked outside + if (action == GLFW_PRESS) + { + for (auto w : m_focus_path) { + Popup* p = dynamic_cast(w); + if (p && !p->contains(m_mouse_pos)) { + for (auto widget : p->parent_window()->children()) { + PopupButton* b = dynamic_cast(widget); + + // we unpush the PopupButton that triggered the Popup-Window only, + // if the user is clicking outside of this PopupButton + if (b && b->pushed() && !b->contains(m_mouse_pos - p->parent_window()->position())) { + b->set_pushed(false); + if (b->change_callback()) + b->change_callback()(false); + } + } + } + } + } + try { if (m_focus_path.size() > 1) { const Window *window =