Merge pull request #8696 from Robyt3/UI-DoubleClick-LeftMouse-Only

Only activate double-clicks with left mouse button again
This commit is contained in:
heinrich5991 2024-08-07 22:07:10 +00:00 committed by GitHub
commit dd1fb2026d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 10 deletions

View file

@ -1471,7 +1471,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View)
continue; continue;
const bool Inside = Ui()->HotItem() == Friend.ListItemId() || Ui()->HotItem() == Friend.RemoveButtonId() || Ui()->HotItem() == Friend.CommunityTooltipId(); 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()) if(Friend.ServerInfo())
{ {
GameClient()->m_Tooltips.DoToolTip(Friend.ListItemId(), &Rect, Localize("Click to select server. Double click to join your friend.")); 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)) if(Ui()->DoButtonLogic(Friend.RemoveButtonId(), 0, &RemoveButton))
{ {
m_pRemoveFriend = &Friend; 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.")); 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); str_copy(g_Config.m_UiServerAddress, Friend.ServerInfo()->m_aAddress);
m_ServerBrowserShouldRevealSelection = true; m_ServerBrowserShouldRevealSelection = true;
if(Ui()->DoDoubleClickLogic(Friend.ListItemId())) if(ButtonResult == 1 && Ui()->DoDoubleClickLogic(Friend.ListItemId()))
{ {
Connect(g_Config.m_UiServerAddress); Connect(g_Config.m_UiServerAddress);
} }

View file

@ -160,24 +160,20 @@ CListboxItem CListBox::DoNextItem(const void *pId, bool Selected, float CornerRa
} }
CListboxItem Item = DoNextRow(); CListboxItem Item = DoNextRow();
bool ItemClicked = false; const int ItemClicked = Item.m_Visible ? Ui()->DoButtonLogic(pId, 0, &Item.m_Rect) : 0;
if(ItemClicked)
if(Item.m_Visible && Ui()->DoButtonLogic(pId, 0, &Item.m_Rect))
{ {
ItemClicked = true;
m_ListBoxNewSelected = ThisItemIndex; m_ListBoxNewSelected = ThisItemIndex;
m_ListBoxItemSelected = true; m_ListBoxItemSelected = true;
m_Active = true; m_Active = true;
} }
else
ItemClicked = false;
// process input, regard selected index // process input, regard selected index
if(m_ListBoxNewSelected == ThisItemIndex) if(m_ListBoxNewSelected == ThisItemIndex)
{ {
if(m_Active) 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; m_ListBoxItemActivated = true;
Ui()->SetActiveItem(nullptr); Ui()->SetActiveItem(nullptr);