1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

handle double-click in Town Portal dialog

This commit is contained in:
Andrey Filipenkov
2023-01-23 15:43:55 +03:00
parent a19c9eccc4
commit 08b04a3527
3 changed files with 13 additions and 2 deletions

View File

@@ -284,6 +284,8 @@ void CGuiHandler::handleCurrentEvent()
switch(current->button.button)
{
case SDL_BUTTON_LEFT:
{
auto doubleClicked = false;
if(lastClick == current->motion && (SDL_GetTicks() - lastClickTime) < 300)
{
std::list<CIntObject*> hlp = doubleClickInterested;
@@ -293,6 +295,7 @@ void CGuiHandler::handleCurrentEvent()
if((*i)->pos.isInside(current->motion.x, current->motion.y))
{
(*i)->onDoubleClick();
doubleClicked = true;
}
}
@@ -301,8 +304,10 @@ void CGuiHandler::handleCurrentEvent()
lastClick = current->motion;
lastClickTime = SDL_GetTicks();
handleMouseButtonClick(lclickable, EIntObjMouseBtnType::LEFT, true);
if(!doubleClicked)
handleMouseButtonClick(lclickable, EIntObjMouseBtnType::LEFT, true);
break;
}
case SDL_BUTTON_RIGHT:
handleMouseButtonClick(rclickable, EIntObjMouseBtnType::RIGHT, true);
break;