1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Merge pull request #3927 from IvanSavenko/fix_doubleclick

[1.5.1] Fixed mouse double-click handling in some widgets
This commit is contained in:
Ivan Savenko 2024-05-11 21:57:15 +03:00 committed by GitHub
commit a341abbd31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 2 deletions

View File

@ -358,6 +358,17 @@ void SelectionTab::clickDouble(const Point & cursorPosition)
if(itemIndex >= curItems.size()) if(itemIndex >= curItems.size())
return; return;
auto clickedItem = curItems[itemIndex];
auto selectedItem = getSelectedMapInfo();
if (clickedItem != selectedItem)
{
// double-click BUT player hit different item than he had selected
// ignore - clickReleased would still trigger and update selection.
// After which another (3rd) click if it happens would still register as double-click
return;
}
if(itemIndex >= 0 && curItems[itemIndex]->isFolder) if(itemIndex >= 0 && curItems[itemIndex]->isFolder)
{ {
select(position); select(position);

View File

@ -335,8 +335,15 @@ void CSelectableComponent::clickPressed(const Point & cursorPosition)
void CSelectableComponent::clickDouble(const Point & cursorPosition) void CSelectableComponent::clickDouble(const Point & cursorPosition)
{ {
if(onChoose) if (!selected)
onChoose(); {
clickPressed(cursorPosition);
}
else
{
if (onChoose)
onChoose();
}
} }
void CSelectableComponent::init() void CSelectableComponent::init()

View File

@ -616,6 +616,9 @@ void CTavernWindow::HeroPortrait::clickDouble(const Point & cursorPosition)
void CTavernWindow::HeroPortrait::showPopupWindow(const Point & cursorPosition) void CTavernWindow::HeroPortrait::showPopupWindow(const Point & cursorPosition)
{ {
// h3 behavior - right-click also selects hero
clickPressed(cursorPosition);
if(h) if(h)
GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(h)); GH.windows().createAndPushWindow<CRClickPopupInt>(std::make_shared<CHeroWindow>(h));
} }
@ -1712,6 +1715,12 @@ void CObjectListWindow::CItem::clickPressed(const Point & cursorPosition)
void CObjectListWindow::CItem::clickDouble(const Point & cursorPosition) void CObjectListWindow::CItem::clickDouble(const Point & cursorPosition)
{ {
if (parent->selected != index)
{
clickPressed(cursorPosition);
return;
}
parent->elementSelected(); parent->elementSelected();
} }