mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-27 13:13:27 +00:00
Adds Skip method to SGUIMessage which works more or less like wxEvent.Skip: GUI objects can allow other event handlers to process an input event after they finish.
Allows hotkey handling of mousewheel events after minimap. Fixes #673. Adds SendEvent to GUI objects, used in place of separate calls to HandleMessage and ScriptEvent. This was SVN commit r9340.
This commit is contained in:
@@ -217,24 +217,21 @@ void IGUIObject::UpdateMouseOver(IGUIObject * const &pMouseOver)
|
||||
if (!m_MouseHovering)
|
||||
{
|
||||
// It wasn't hovering, so that must mean it just entered
|
||||
HandleMessage(GUIM_MOUSE_ENTER);
|
||||
ScriptEvent("mouseenter");
|
||||
SendEvent(GUIM_MOUSE_ENTER, "mouseenter");
|
||||
}
|
||||
|
||||
// Either way, set to true
|
||||
m_MouseHovering = true;
|
||||
|
||||
// call mouse over
|
||||
HandleMessage(GUIM_MOUSE_OVER);
|
||||
ScriptEvent("mousemove");
|
||||
SendEvent(GUIM_MOUSE_OVER, "mousemove");
|
||||
}
|
||||
else // Some other object (or none) is hovered
|
||||
{
|
||||
if (m_MouseHovering)
|
||||
{
|
||||
m_MouseHovering = false;
|
||||
HandleMessage(GUIM_MOUSE_LEAVE);
|
||||
ScriptEvent("mouseleave");
|
||||
SendEvent(GUIM_MOUSE_LEAVE, "mouseleave");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,8 +450,7 @@ void IGUIObject::CheckSettingsValidity()
|
||||
try
|
||||
{
|
||||
// Send message to itself
|
||||
HandleMessage(GUIM_SETTINGS_UPDATED);
|
||||
ScriptEvent("update");
|
||||
SendEvent(GUIM_SETTINGS_UPDATED, "update");
|
||||
}
|
||||
catch (PSERROR_GUI&)
|
||||
{
|
||||
@@ -497,6 +493,16 @@ void IGUIObject::SetScriptHandler(const CStr& Action, JSObject* Function)
|
||||
m_ScriptHandlers[Action] = obj;
|
||||
}
|
||||
|
||||
InReaction IGUIObject::SendEvent(EGUIMessageType type, const CStr& EventName)
|
||||
{
|
||||
SGUIMessage msg(type);
|
||||
HandleMessage(msg);
|
||||
|
||||
ScriptEvent(EventName);
|
||||
|
||||
return (msg.skipped ? IN_PASS : IN_HANDLED);
|
||||
}
|
||||
|
||||
void IGUIObject::ScriptEvent(const CStr& Action)
|
||||
{
|
||||
std::map<CStr, JSObject**>::iterator it = m_ScriptHandlers.find(Action);
|
||||
|
||||
Reference in New Issue
Block a user