- In flash 10, oh yay, the mouseTarget might be set to null for security

reasons.
- While I was in there, I renamed the method to createCommandContextMenuItem,
  since that's more what it is.
- Removed the silly-ass option to make the menu item invisible. It was there
  because ContextMenuItem has it, but how about you just don't add the item?


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@820 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Ray Greenwell
2009-05-13 23:18:48 +00:00
parent 21b70ac753
commit 9c4173fd8b
+7 -8
View File
@@ -31,18 +31,17 @@ import com.threerings.util.CommandEvent;
public class MenuUtil public class MenuUtil
{ {
/** /**
* Create a menu item that will submit a controller command when selected. * Create a context menu item that will submit a command when selected.
*/ */
public static function createControllerMenuItem ( public static function createCommandContextMenuItem (
caption :String, cmdOrFn :Object, arg :Object = null, caption :String, cmdOrFn :Object, arg :Object = null,
separatorBefore :Boolean = false, enabled :Boolean = true, separatorBefore :Boolean = false, enabled :Boolean = true) :ContextMenuItem
visible :Boolean = true) :ContextMenuItem
{ {
var item :ContextMenuItem = var item :ContextMenuItem = new ContextMenuItem(caption, separatorBefore, enabled);
new ContextMenuItem(caption, separatorBefore, enabled, visible);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,
function (event :ContextMenuEvent) :void { function (event :ContextMenuEvent) :void {
CommandEvent.dispatch(event.mouseTarget, cmdOrFn, arg); // mouseTarget may be null due to security reasons
CommandEvent.dispatch(event.mouseTarget || event.contextMenuOwner, cmdOrFn, arg);
}); });
return item; return item;
} }