unbind a key with right mouse button in the controls menu. Closes #67

This commit is contained in:
oy 2010-09-12 17:15:09 +02:00
parent 901427809f
commit c52ee7baa9
2 changed files with 28 additions and 8 deletions

View file

@ -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
{

View file

@ -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);
}