From 2c7c391ff077951d977f158367d200f870a5f749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Wed, 7 Aug 2024 20:55:58 +0200 Subject: [PATCH] Only activate double-clicks with left mouse button again Double-clicks could also be activated with other mouse buttons on some UI elements, which was unintentionally added by #8489. --- src/game/client/components/menus_browser.cpp | 6 +++--- src/game/client/ui_listbox.cpp | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index a3d6898a6..d975b37ff 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -1471,7 +1471,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) continue; const bool Inside = Ui()->HotItem() == Friend.ListItemId() || Ui()->HotItem() == Friend.RemoveButtonId() || Ui()->HotItem() == Friend.CommunityTooltipId(); - bool ButtonResult = Ui()->DoButtonLogic(Friend.ListItemId(), 0, &Rect); + int ButtonResult = Ui()->DoButtonLogic(Friend.ListItemId(), 0, &Rect); if(Friend.ServerInfo()) { GameClient()->m_Tooltips.DoToolTip(Friend.ListItemId(), &Rect, Localize("Click to select server. Double click to join your friend.")); @@ -1553,7 +1553,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) if(Ui()->DoButtonLogic(Friend.RemoveButtonId(), 0, &RemoveButton)) { m_pRemoveFriend = &Friend; - ButtonResult = false; + ButtonResult = 0; } GameClient()->m_Tooltips.DoToolTip(Friend.RemoveButtonId(), &RemoveButton, Friend.FriendState() == IFriends::FRIEND_PLAYER ? Localize("Click to remove this player from your friends list.") : Localize("Click to remove this clan from your friends list.")); } @@ -1563,7 +1563,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) { str_copy(g_Config.m_UiServerAddress, Friend.ServerInfo()->m_aAddress); m_ServerBrowserShouldRevealSelection = true; - if(Ui()->DoDoubleClickLogic(Friend.ListItemId())) + if(ButtonResult == 1 && Ui()->DoDoubleClickLogic(Friend.ListItemId())) { Connect(g_Config.m_UiServerAddress); } diff --git a/src/game/client/ui_listbox.cpp b/src/game/client/ui_listbox.cpp index 87620a9d4..2a84aebd7 100644 --- a/src/game/client/ui_listbox.cpp +++ b/src/game/client/ui_listbox.cpp @@ -160,24 +160,20 @@ CListboxItem CListBox::DoNextItem(const void *pId, bool Selected, float CornerRa } CListboxItem Item = DoNextRow(); - bool ItemClicked = false; - - if(Item.m_Visible && Ui()->DoButtonLogic(pId, 0, &Item.m_Rect)) + const int ItemClicked = Item.m_Visible ? Ui()->DoButtonLogic(pId, 0, &Item.m_Rect) : 0; + if(ItemClicked) { - ItemClicked = true; m_ListBoxNewSelected = ThisItemIndex; m_ListBoxItemSelected = true; m_Active = true; } - else - ItemClicked = false; // process input, regard selected index if(m_ListBoxNewSelected == ThisItemIndex) { if(m_Active) { - if(Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER) || (ItemClicked && Ui()->DoDoubleClickLogic(pId))) + if(Ui()->ConsumeHotkey(CUi::HOTKEY_ENTER) || (ItemClicked == 1 && Ui()->DoDoubleClickLogic(pId))) { m_ListBoxItemActivated = true; Ui()->SetActiveItem(nullptr);