mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
unbind a key with right mouse button in the controls menu. Closes #67
This commit is contained in:
parent
901427809f
commit
c52ee7baa9
|
@ -449,10 +449,11 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key)
|
|||
// process
|
||||
static void *pGrabbedID = 0;
|
||||
static bool MouseReleased = true;
|
||||
static int ButtonUsed = 0;
|
||||
int Inside = UI()->MouseInside(pRect);
|
||||
int NewKey = Key;
|
||||
|
||||
if(!UI()->MouseButton(0) && pGrabbedID == pID)
|
||||
if(!UI()->MouseButton(0) && !UI()->MouseButton(1) && pGrabbedID == pID)
|
||||
MouseReleased = true;
|
||||
|
||||
if(UI()->ActiveItem() == pID)
|
||||
|
@ -467,14 +468,31 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key)
|
|||
MouseReleased = false;
|
||||
pGrabbedID = pID;
|
||||
}
|
||||
|
||||
if(ButtonUsed == 1 && !UI()->MouseButton(1))
|
||||
{
|
||||
if(Inside)
|
||||
NewKey = 0;
|
||||
UI()->SetActiveItem(0);
|
||||
}
|
||||
}
|
||||
else if(UI()->HotItem() == pID)
|
||||
{
|
||||
if(UI()->MouseButton(0) && MouseReleased)
|
||||
if(MouseReleased)
|
||||
{
|
||||
m_Binder.m_TakeKey = true;
|
||||
m_Binder.m_GotKey = false;
|
||||
UI()->SetActiveItem(pID);
|
||||
if(UI()->MouseButton(0))
|
||||
{
|
||||
m_Binder.m_TakeKey = true;
|
||||
m_Binder.m_GotKey = false;
|
||||
UI()->SetActiveItem(pID);
|
||||
ButtonUsed = 0;
|
||||
}
|
||||
|
||||
if(UI()->MouseButton(1))
|
||||
{
|
||||
UI()->SetActiveItem(pID);
|
||||
ButtonUsed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +500,7 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key)
|
|||
UI()->SetHotItem(pID);
|
||||
|
||||
// draw
|
||||
if (UI()->ActiveItem() == pID)
|
||||
if (UI()->ActiveItem() == pID && ButtonUsed == 0)
|
||||
DoButton_KeySelect(pID, "???", 0, pRect);
|
||||
else
|
||||
{
|
||||
|
|
|
@ -337,8 +337,10 @@ void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View)
|
|||
int NewId = DoKeyReader((void *)&gs_aKeys[i].m_Name, &Button, OldId);
|
||||
if(NewId != OldId)
|
||||
{
|
||||
m_pClient->m_pBinds->Bind(OldId, "");
|
||||
m_pClient->m_pBinds->Bind(NewId, gs_aKeys[i].m_pCommand);
|
||||
if(OldId != 0 || NewId == 0)
|
||||
m_pClient->m_pBinds->Bind(OldId, "");
|
||||
if(NewId != 0)
|
||||
m_pClient->m_pBinds->Bind(NewId, gs_aKeys[i].m_pCommand);
|
||||
}
|
||||
View.HSplitTop(5.0f, 0, &View);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue