From 9c4173fd8b68241528751638dd661d78a4287887 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Wed, 13 May 2009 23:18:48 +0000 Subject: [PATCH] - 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 --- src/as/com/threerings/flash/MenuUtil.as | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/as/com/threerings/flash/MenuUtil.as b/src/as/com/threerings/flash/MenuUtil.as index 57f07bc2..6e66e95a 100644 --- a/src/as/com/threerings/flash/MenuUtil.as +++ b/src/as/com/threerings/flash/MenuUtil.as @@ -31,18 +31,17 @@ import com.threerings.util.CommandEvent; 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 ( - caption :String, cmdOrFn :Object, arg :Object = null, - separatorBefore :Boolean = false, enabled :Boolean = true, - visible :Boolean = true) :ContextMenuItem + public static function createCommandContextMenuItem ( + caption :String, cmdOrFn :Object, arg :Object = null, + separatorBefore :Boolean = false, enabled :Boolean = true) :ContextMenuItem { - var item :ContextMenuItem = - new ContextMenuItem(caption, separatorBefore, enabled, visible); + var item :ContextMenuItem = new ContextMenuItem(caption, separatorBefore, enabled); item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, 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; }