1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

Enter popup await mode only if there is an active popup

This commit is contained in:
Ivan Savenko
2023-06-11 20:38:42 +03:00
parent e9788e2904
commit 85a11c090e
13 changed files with 77 additions and 46 deletions

View File

@@ -14,6 +14,7 @@
#include "FramerateManager.h"
#include "CGuiHandler.h"
#include "MouseButton.h"
#include "WindowHandler.h"
#include "../../lib/Point.h"
@@ -130,26 +131,20 @@ void EventDispatcher::dispatchMouseDoubleClick(const Point & position)
}
if(!doubleClicked)
dispatchMouseButtonPressed(MouseButton::LEFT, position);
}
void EventDispatcher::dispatchMouseButtonPressed(const MouseButton & button, const Point & position)
{
if (button == MouseButton::LEFT)
handleLeftButtonClick(true);
if (button == MouseButton::RIGHT)
handleRightButtonClick(true);
}
void EventDispatcher::dispatchMouseButtonReleased(const MouseButton & button, const Point & position)
void EventDispatcher::dispatchMouseLeftButtonPressed(const Point & position)
{
if (button == MouseButton::LEFT)
handleLeftButtonClick(false);
if (button == MouseButton::RIGHT)
handleRightButtonClick(false);
handleLeftButtonClick(true);
}
void EventDispatcher::handleRightButtonClick(bool isPressed)
void EventDispatcher::dispatchMouseLeftButtonReleased(const Point & position)
{
handleLeftButtonClick(false);
}
void EventDispatcher::dispatchShowPopup(const Point & position)
{
auto hlp = rclickable;
for(auto & i : hlp)
@@ -157,14 +152,21 @@ void EventDispatcher::handleRightButtonClick(bool isPressed)
if(!vstd::contains(rclickable, i))
continue;
if( isPressed && i->receiveEvent(GH.getCursorPosition(), AEventsReceiver::LCLICK))
i->showPopupWindow();
if( !i->receiveEvent(GH.getCursorPosition(), AEventsReceiver::LCLICK))
continue;
if(!isPressed)
i->closePopupWindow();
i->showPopupWindow();
}
}
void EventDispatcher::dispatchClosePopup(const Point & position)
{
if (GH.windows().isTopWindowPopup())
GH.windows().popWindows(1);
assert(!GH.windows().isTopWindowPopup());
}
void EventDispatcher::handleLeftButtonClick(bool isPressed)
{
auto hlp = lclickable;