Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CGUI.cpp
Show First 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | InReaction CGUI::HandleEvent(const SDL_Event_* ev) | ||||
// Restore m_MousePos (for delayed mouse button events) | // Restore m_MousePos (for delayed mouse button events) | ||||
if (ev->ev.type == SDL_MOUSEBUTTONDOWN || ev->ev.type == SDL_MOUSEBUTTONUP) | if (ev->ev.type == SDL_MOUSEBUTTONDOWN || ev->ev.type == SDL_MOUSEBUTTONUP) | ||||
m_MousePos = oldMousePos; | m_MousePos = oldMousePos; | ||||
// Handle keys for input boxes | // Handle keys for input boxes | ||||
if (GetFocusedObject()) | if (GetFocusedObject()) | ||||
{ | { | ||||
if ((ev->ev.type == SDL_KEYDOWN && | if (ev->ev.type == SDL_MOUSEBUTTONUP || ev->ev.type == SDL_MOUSEBUTTONDOWN || | ||||
ev->ev.key.keysym.sym != SDLK_ESCAPE && | ev->ev.type == SDL_MOUSEWHEEL || | ||||
!g_keys[SDLK_LCTRL] && !g_keys[SDLK_RCTRL] && | ev->ev.type == SDL_KEYUP || ev->ev.type == SDL_KEYDOWN || | ||||
!g_keys[SDLK_LALT] && !g_keys[SDLK_RALT]) || | ev->ev.type == SDL_HOTKEYUP || ev->ev.type == SDL_HOTKEYDOWN || | ||||
ev->ev.type == SDL_HOTKEYDOWN || | ev->ev.type == SDL_TEXTINPUT || ev->ev.type == SDL_TEXTEDITING) | ||||
ev->ev.type == SDL_TEXTINPUT || | |||||
ev->ev.type == SDL_TEXTEDITING) | |||||
{ | |||||
ret = GetFocusedObject()->ManuallyHandleEvent(ev); | ret = GetFocusedObject()->ManuallyHandleEvent(ev); | ||||
} | |||||
// else will return IN_PASS because we never used the button. | // else will return IN_PASS because we never used the button. | ||||
} | } | ||||
return ret; | return ret; | ||||
} | } | ||||
void CGUI::TickObjects() | void CGUI::TickObjects() | ||||
{ | { | ||||
m_BaseObject.RecurseObject(&IGUIObject::IsHiddenOrGhost, &IGUIObject::Tick); | |||||
SendEventToAll(EventNameTick); | SendEventToAll(EventNameTick); | ||||
m_Tooltip.Update(FindObjectUnderMouse(), m_MousePos, *this); | m_Tooltip.Update(FindObjectUnderMouse(), m_MousePos, *this); | ||||
} | } | ||||
void CGUI::SendEventToAll(const CStr& eventName) | void CGUI::SendEventToAll(const CStr& eventName) | ||||
{ | { | ||||
m_BaseObject.RecurseObject(nullptr, &IGUIObject::ScriptEvent, eventName); | m_BaseObject.RecurseObject(nullptr, &IGUIObject::ScriptEvent, eventName); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 999 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator