Utility method for creating a menu item that will post controller commands.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4194 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,29 @@
|
|||||||
|
package com.threerings.util {
|
||||||
|
|
||||||
|
import flash.ui.ContextMenuItem;
|
||||||
|
import flash.events.ContextMenuEvent;
|
||||||
|
|
||||||
|
import com.threerings.events.ControllerEvent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class MenuUtil
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a menu item that will submit a controller command when selected.
|
||||||
|
*/
|
||||||
|
public static function createControllerMenuItem (
|
||||||
|
caption :String, cmd :String, arg :Object = null,
|
||||||
|
separatorBefore :Boolean = false, enabled :Boolean = true,
|
||||||
|
visible :Boolean = true) :ContextMenuItem
|
||||||
|
{
|
||||||
|
var item :ContextMenuItem =
|
||||||
|
new ContextMenuItem(caption, separatorBefore, enabled, visible);
|
||||||
|
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
|
||||||
|
function (event :ContextMenuEvent) :void {
|
||||||
|
event.mouseTarget.dispatchEvent(new ControllerEvent(cmd, arg));
|
||||||
|
});
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user