Ah, I figured out how to fix up my one issue with controllers:
The default behavior of an event is determined by the entity that calls into the event dispatcher, so the solution was to unify the dispatch of these events. Created a utility method in CommandEvent to do that, and did some singlton-like hackery on the constructor to prevent folks from thinking they can just dispatch these themselves and have it work correctly. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4317 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -22,6 +22,15 @@ public class Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post an action so that it can be handled by this controller or
|
||||
* another controller above it in the display list.
|
||||
*/
|
||||
public final function postAction (cmd :String, arg :Object = null) :void
|
||||
{
|
||||
CommandEvent.dispatch(_panel, cmd, arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an action that was generated by our panel or some child.
|
||||
*
|
||||
@@ -52,10 +61,6 @@ public class Controller
|
||||
// suppress, and fall through
|
||||
}
|
||||
|
||||
// TODO: This warning should really be inside the CommandEvent
|
||||
// somewhere, and only generated if the event never gets cancelled
|
||||
Log.getLog(this).warning("Unhandled controller command " +
|
||||
"[cmd=" + cmd + ", arg=" + arg + "].");
|
||||
return false; // not handled
|
||||
}
|
||||
|
||||
@@ -68,6 +73,7 @@ public class Controller
|
||||
if (handleAction(event.command, event.arg)) {
|
||||
// if we handle the event, stop it from moving outward to another
|
||||
// controller
|
||||
event.preventDefault();
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user