From 94498990989b9142d72d3745aefd94b73118c421 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 9 Jul 2023 15:15:25 +0300 Subject: [PATCH] Fix regressions --- client/gui/EventDispatcher.cpp | 7 ++++--- client/lobby/RandomMapTab.cpp | 8 ++++++++ client/lobby/RandomMapTab.h | 1 + client/widgets/CArtifactHolder.cpp | 10 ++++++++++ client/widgets/CArtifactHolder.h | 2 ++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/client/gui/EventDispatcher.cpp b/client/gui/EventDispatcher.cpp index 732e5db53..d412ebf94 100644 --- a/client/gui/EventDispatcher.cpp +++ b/client/gui/EventDispatcher.cpp @@ -180,12 +180,13 @@ void EventDispatcher::handleLeftButtonClick(const Point & position, bool isPress if( i->receiveEvent(GH.getCursorPosition(), AEventsReceiver::LCLICK)) { - i->mouseClickedState = isPressed; - if(isPressed) i->clickPressed(position); - else + + if (i->mouseClickedState && !isPressed) i->clickReleased(position); + + i->mouseClickedState = isPressed; } else { diff --git a/client/lobby/RandomMapTab.cpp b/client/lobby/RandomMapTab.cpp index 3881f40a1..68833f4a9 100644 --- a/client/lobby/RandomMapTab.cpp +++ b/client/lobby/RandomMapTab.cpp @@ -471,6 +471,14 @@ void TemplatesDropBox::sliderMove(int slidPos) redraw(); } +bool TemplatesDropBox::receiveEvent(const Point & position, int eventType) const +{ + if (eventType == LCLICK) + return true; // we want drop box to close when clicking outside drop box borders + + return CIntObject::receiveEvent(position, eventType); +} + void TemplatesDropBox::clickPressed(const Point & cursorPosition) { if (!pos.isInside(cursorPosition)) diff --git a/client/lobby/RandomMapTab.h b/client/lobby/RandomMapTab.h index 8f6098559..356085ab5 100644 --- a/client/lobby/RandomMapTab.h +++ b/client/lobby/RandomMapTab.h @@ -71,6 +71,7 @@ class TemplatesDropBox : public InterfaceObjectConfigurable public: TemplatesDropBox(RandomMapTab & randomMapTab, int3 size); + bool receiveEvent(const Point & position, int eventType) const override; void clickPressed(const Point & cursorPosition) override; void setTemplate(const CRmgTemplate *); diff --git a/client/widgets/CArtifactHolder.cpp b/client/widgets/CArtifactHolder.cpp index 2ed7cfdff..3ee1b5b79 100644 --- a/client/widgets/CArtifactHolder.cpp +++ b/client/widgets/CArtifactHolder.cpp @@ -122,6 +122,11 @@ void CCommanderArtPlace::clickPressed(const Point & cursorPosition) LOCPLINT->showYesNoDialog(CGI->generaltexth->translate("vcmi.commanderWindow.artifactMessage"), [this]() { returnArtToHeroCallback(); }, []() {}); } +void CCommanderArtPlace::clickReleased(const Point & cursorPosition) +{ + // No-op override +} + void CCommanderArtPlace::showPopupWindow(const Point & cursorPosition) { if(ourArt && text.size()) @@ -184,6 +189,11 @@ void CHeroArtPlace::clickPressed(const Point & cursorPosition) leftClickCallback(*this); } +void CHeroArtPlace::clickReleased(const Point & cursorPosition) +{ + // No-op override +} + void CHeroArtPlace::showPopupWindow(const Point & cursorPosition) { if(rightClickCallback) diff --git a/client/widgets/CArtifactHolder.h b/client/widgets/CArtifactHolder.h index d8cc43aba..b52ef5ca3 100644 --- a/client/widgets/CArtifactHolder.h +++ b/client/widgets/CArtifactHolder.h @@ -58,6 +58,7 @@ protected: public: CCommanderArtPlace(Point position, const CGHeroInstance * commanderOwner, ArtifactPosition artSlot, const CArtifactInstance * Art = nullptr); void clickPressed(const Point & cursorPosition) override; + void clickReleased(const Point & cursorPosition) override; void showPopupWindow(const Point & cursorPosition) override; void setArtifact(const CArtifactInstance * art) override; }; @@ -77,6 +78,7 @@ public: void selectSlot(bool on); bool isMarked() const; void clickPressed(const Point & cursorPosition) override; + void clickReleased(const Point & cursorPosition) override; void showPopupWindow(const Point & cursorPosition) override; void showAll(Canvas & to) override; void setArtifact(const CArtifactInstance * art) override;