From 7c5dcfd47b42b0da4ddfaada9a358e0e8e6b77be Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 22 Jun 2023 22:34:05 +0300 Subject: [PATCH] Fix closing dropdown box via clicking outside bounds --- client/lobby/RandomMapTab.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/client/lobby/RandomMapTab.cpp b/client/lobby/RandomMapTab.cpp index 71409a32c..efbf1825c 100644 --- a/client/lobby/RandomMapTab.cpp +++ b/client/lobby/RandomMapTab.cpp @@ -447,6 +447,11 @@ TemplatesDropBox::TemplatesDropBox(RandomMapTab & randomMapTab, int3 size): { w->setAmount(curItems.size()); } + + //FIXME: this should be done by InterfaceObjectConfigurable, but might have side-effects + pos = children.front()->pos; + for (auto const & child : children) + pos = pos.include(child->pos); updateListItems(); } @@ -469,16 +474,10 @@ void TemplatesDropBox::sliderMove(int slidPos) void TemplatesDropBox::clickLeft(tribool down, bool previousState) { - if(down && !isActive()) + if (!pos.isInside(GH.getCursorPosition())) { - auto w = widget("slider"); - - // pop the interface only if the mouse is not clicking on the slider - if (!w || !w->isMouseLeftButtonPressed()) - { - assert(GH.windows().isTopWindow(this)); - GH.windows().popWindows(1); - } + assert(GH.windows().isTopWindow(this)); + GH.windows().popWindows(1); } }