Renamed ControllerEvent to CommandEvent.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4281 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -27,8 +27,6 @@ import com.threerings.crowd.data.PlaceConfig;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.util.CrowdContext;
|
||||
|
||||
import com.threerings.events.ControllerEvent;
|
||||
|
||||
/**
|
||||
* Controls the user interface that is used to display a place. When the
|
||||
* client moves to a new place, the appropriate place controller is
|
||||
|
||||
@@ -4,7 +4,7 @@ import flash.events.MouseEvent;
|
||||
|
||||
import mx.controls.Button;
|
||||
|
||||
import com.threerings.events.ControllerEvent;
|
||||
import com.threerings.mx.events.CommandEvent;
|
||||
|
||||
/**
|
||||
* A command button simply dispatches a Controller command (with an optional
|
||||
@@ -37,7 +37,7 @@ public class CommandButton extends Button
|
||||
// stop the click event
|
||||
event.stopImmediatePropagation();
|
||||
// dispatch the command event
|
||||
dispatchEvent(new ControllerEvent(_cmd, _arg));
|
||||
dispatchEvent(new CommandEvent(_cmd, _arg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,16 +1,16 @@
|
||||
package com.threerings.events {
|
||||
package com.threerings.mx.events {
|
||||
|
||||
import flash.events.Event;
|
||||
|
||||
public class ControllerEvent extends Event
|
||||
public class CommandEvent extends Event
|
||||
{
|
||||
/** The event type for all controller events. */
|
||||
public static const TYPE :String = "controller";
|
||||
public static const TYPE :String = "commandEvt";
|
||||
|
||||
public var command :String;
|
||||
public var arg :Object;
|
||||
|
||||
public function ControllerEvent (command :String, arg :Object = null)
|
||||
public function CommandEvent (command :String, arg :Object = null)
|
||||
{
|
||||
super(TYPE, true);
|
||||
this.command = command;
|
||||
@@ -19,12 +19,12 @@ public class ControllerEvent extends Event
|
||||
|
||||
override public function clone () :Event
|
||||
{
|
||||
return new ControllerEvent(command, arg);
|
||||
return new CommandEvent(command, arg);
|
||||
}
|
||||
|
||||
override public function toString () :String
|
||||
{
|
||||
return "ControllerEvent[" + command + " (" + arg + ")]";
|
||||
return "CommandEvent[" + command + " (" + arg + ")]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.threerings.util {
|
||||
|
||||
import flash.events.IEventDispatcher;
|
||||
|
||||
import com.threerings.events.ControllerEvent;
|
||||
import com.threerings.mx.events.CommandEvent;
|
||||
|
||||
public class Controller
|
||||
{
|
||||
@@ -13,12 +13,12 @@ public class Controller
|
||||
{
|
||||
if (_panel != null) {
|
||||
_panel.removeEventListener(
|
||||
ControllerEvent.TYPE, handleControllerEvent);
|
||||
CommandEvent.TYPE, handleCommandEvent);
|
||||
}
|
||||
_panel = panel;
|
||||
if (_panel != null) {
|
||||
_panel.addEventListener(
|
||||
ControllerEvent.TYPE, handleControllerEvent);
|
||||
CommandEvent.TYPE, handleCommandEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,25 @@ public class Controller
|
||||
*/
|
||||
public function handleAction (cmd :String, arg :Object) :Boolean
|
||||
{
|
||||
// TODO: This warning should really be inside the ControllerEvent
|
||||
// fall back to a method named the cmd
|
||||
try {
|
||||
var fn :Function = (this["handle" + cmd] as Function);
|
||||
if (fn != null) {
|
||||
try {
|
||||
fn(arg);
|
||||
} catch (e :Error) {
|
||||
Log.getLog(this).warning("Error handling controller " +
|
||||
"command [error=" + e + ", cmd=" + cmd +
|
||||
", arg=" + arg + "].");
|
||||
}
|
||||
// we "handled" the event, even if it threw an error
|
||||
return true;
|
||||
}
|
||||
} catch (e :Error) {
|
||||
// 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 + "].");
|
||||
@@ -43,7 +61,7 @@ public class Controller
|
||||
* Private function to handle the controller event and call
|
||||
* handleAction.
|
||||
*/
|
||||
private function handleControllerEvent (event :ControllerEvent) :void
|
||||
private function handleCommandEvent (event :CommandEvent) :void
|
||||
{
|
||||
if (handleAction(event.command, event.arg)) {
|
||||
// if we handle the event, stop it from moving outward to another
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.threerings.util {
|
||||
import flash.ui.ContextMenuItem;
|
||||
import flash.events.ContextMenuEvent;
|
||||
|
||||
import com.threerings.events.ControllerEvent;
|
||||
import com.threerings.mx.events.CommandEvent;
|
||||
|
||||
/**
|
||||
*/
|
||||
@@ -21,7 +21,7 @@ public class MenuUtil
|
||||
new ContextMenuItem(caption, separatorBefore, enabled, visible);
|
||||
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
|
||||
function (event :ContextMenuEvent) :void {
|
||||
event.mouseTarget.dispatchEvent(new ControllerEvent(cmd, arg));
|
||||
event.mouseTarget.dispatchEvent(new CommandEvent(cmd, arg));
|
||||
});
|
||||
return item;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user