Flex Gumbo中如何通过contextMenu属性实现自定义右键弹出菜单的例子
By Minidxer | May 18, 2009
接下来的例子演示了Flex Gumbo中如何通过创建ContextMenuItem并将其通过contextMenu属性加到customItems数组,实现自定义右键弹出菜单。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application name="Application_contextMenu_test"
- xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white"
- initialize="init();">
- <mx:Script>
- <![CDATA[
- private function init():void {
- var customMenuItem1:ContextMenuItem = new ContextMenuItem("Flex SDK " + mx_internal::VERSION, false, false);
- var customMenuItem2:ContextMenuItem = new ContextMenuItem("Player " + Capabilities.version, false, false);
- var contextMenuCustomItems:Array = application.contextMenu.customItems;
- contextMenuCustomItems.push(customMenuItem1);
- contextMenuCustomItems.push(customMenuItem2);
- }
- ]]>
- </mx:Script>
- <mx:Label text="Right click to see custom context menu items." />
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子
Topics:
Gumbo, Other |
No Comments » |
Tags: ContextMenu, ContextMenuItem, customItems