From 5847ee1e994e2cd20f4a74413fe2bf16cf5973ab Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Sat, 23 Feb 2008 01:41:51 +0000 Subject: [PATCH] Fix to work with Flex 3. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@428 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flex/CommandMenu.as | 25 +++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/as/com/threerings/flex/CommandMenu.as b/src/as/com/threerings/flex/CommandMenu.as index 37900874..28543914 100644 --- a/src/as/com/threerings/flex/CommandMenu.as +++ b/src/as/com/threerings/flex/CommandMenu.as @@ -31,6 +31,7 @@ import mx.controls.Menu; import mx.controls.listClasses.BaseListData; import mx.controls.listClasses.IListItemRenderer; import mx.controls.menuClasses.IMenuItemRenderer; +import mx.controls.menuClasses.MenuListData; import mx.core.mx_internal; import mx.core.Application; @@ -288,8 +289,28 @@ public class CommandMenu extends Menu // from List override protected function makeListData (data :Object, uid :String, rowNum :int) :BaseListData { - return new CommandListData(itemToLabel(data), itemToIcon(data), - getItemProp(data, "iconObject") as IFlexDisplayObject, labelField, uid, this, rowNum); + // Oh, FFS. + // We need to set up these "maxMeasuredIconWidth" fields on the MenuListData, but our + // superclass has made those variables private. + // We can get the values out of another MenuListData, so we just always call super() + // to create one of those, and if we need to make a CommandListData, we construct one + // from the fields in the MenuListData. + + var menuListData :MenuListData = super.makeListData(data, uid, rowNum) as MenuListData; + + var iconObject :IFlexDisplayObject = getItemProp(data, "iconObject") as IFlexDisplayObject; + if (iconObject != null) { + var cmdListData :CommandListData = new CommandListData(menuListData.label, + menuListData.icon, iconObject, labelField, uid, this, rowNum); + + cmdListData.maxMeasuredIconWidth = menuListData.maxMeasuredIconWidth; + cmdListData.maxMeasuredTypeIconWidth = menuListData.maxMeasuredTypeIconWidth; + cmdListData.maxMeasuredBranchIconWidth = menuListData.maxMeasuredBranchIconWidth; + cmdListData.useTwoColumns = menuListData.useTwoColumns; + return cmdListData; + } + + return menuListData; } /**