forked from 0ad/0ad
Changed GUI mouse event handling so that button events use the mouse position at the time of the button state change. Fixed minimap message handling to respect out-of-order events. Fixes #669
This was SVN commit r8610.
This commit is contained in:
parent
6b444ea23b
commit
293e5e33ec
@ -116,6 +116,13 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
}
|
||||
}
|
||||
|
||||
// Update m_MousePos (for delayed mouse button events)
|
||||
CPos oldMousePos = m_MousePos;
|
||||
if (ev->ev.type == SDL_MOUSEBUTTONDOWN || ev->ev.type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
m_MousePos = CPos((float)ev->ev.button.x, (float)ev->ev.button.y);
|
||||
}
|
||||
|
||||
// Only one object can be hovered
|
||||
IGUIObject *pNearest = NULL;
|
||||
|
||||
@ -284,6 +291,12 @@ InReaction CGUI::HandleEvent(const SDL_Event_* ev)
|
||||
}
|
||||
}
|
||||
|
||||
// Restore m_MousePos (for delayed mouse button events)
|
||||
if (ev->ev.type == SDL_MOUSEBUTTONDOWN || ev->ev.type == SDL_MOUSEBUTTONUP)
|
||||
{
|
||||
m_MousePos = oldMousePos;
|
||||
}
|
||||
|
||||
// Handle keys for input boxes
|
||||
if (GetFocusedObject())
|
||||
{
|
||||
|
@ -60,6 +60,7 @@ CMiniMap::CMiniMap()
|
||||
AddSetting(GUIST_CStr, "tooltip");
|
||||
AddSetting(GUIST_CStr, "tooltip_style");
|
||||
m_Clicking = false;
|
||||
m_Hovering = false;
|
||||
|
||||
m_LOSScale = 2;
|
||||
}
|
||||
@ -74,34 +75,38 @@ void CMiniMap::HandleMessage(const SGUIMessage &Message)
|
||||
switch(Message.type)
|
||||
{
|
||||
case GUIM_MOUSE_PRESS_LEFT:
|
||||
{
|
||||
if (m_Hovering)
|
||||
{
|
||||
SetCameraPos();
|
||||
m_Clicking = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GUIM_MOUSE_RELEASE_LEFT:
|
||||
{
|
||||
if(m_Clicking)
|
||||
if(m_Hovering && m_Clicking)
|
||||
{
|
||||
SetCameraPos();
|
||||
}
|
||||
m_Clicking = false;
|
||||
break;
|
||||
}
|
||||
case GUIM_MOUSE_DBLCLICK_LEFT:
|
||||
{
|
||||
if(m_Clicking)
|
||||
if(m_Hovering && m_Clicking)
|
||||
SetCameraPos();
|
||||
m_Clicking = false;
|
||||
break;
|
||||
}
|
||||
case GUIM_MOUSE_ENTER:
|
||||
{
|
||||
// g_Selection.m_mouseOverMM = true;
|
||||
m_Hovering = true;
|
||||
break;
|
||||
}
|
||||
case GUIM_MOUSE_LEAVE:
|
||||
{
|
||||
// g_Selection.m_mouseOverMM = false;
|
||||
m_Clicking = false;
|
||||
m_Hovering = false;
|
||||
break;
|
||||
}
|
||||
case GUIM_MOUSE_RELEASE_RIGHT:
|
||||
@ -116,7 +121,7 @@ void CMiniMap::HandleMessage(const SGUIMessage &Message)
|
||||
}
|
||||
case GUIM_MOUSE_MOTION:
|
||||
{
|
||||
if (m_Clicking)
|
||||
if (m_Hovering && m_Clicking)
|
||||
SetCameraPos();
|
||||
break;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ protected:
|
||||
|
||||
//Whether or not the mouse is currently down
|
||||
bool m_Clicking;
|
||||
bool m_Hovering;
|
||||
|
||||
// minimap texture handles
|
||||
GLuint m_TerrainTexture;
|
||||
|
Loading…
Reference in New Issue
Block a user