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:
historic_bruno
2011-04-28 20:42:11 +00:00
parent 9d5539a215
commit 67ca7461cd
38 changed files with 188 additions and 150 deletions
+14 -8
View File
@@ -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);