Adobe AIR的 - 添加上下文菜单上单击树节点的权 [英] Adobe air - add context menu on right click of tree node
问题描述
我使用的Adobe AIR的创建一个桌面应用程序。在该申请中我有一棵树,我想添加菜单节点时是正确的点击。我跟他们说了弯曲的树,但没有工作的方式。
I am using Adobe Air to create a desktop application. In that application I have a tree and i want to add menu to a node when it right clicked. I followed the way they are saying for flex tree, but not working.
任何操作方法?
〜Umesh制作
推荐答案
我不完全相信你的问题是什么,因为你不说是否没有编制,没有显示器或给了一个运行时错误等,所以我把一个MXML来证明它。在code主要是从树和菜单的例子拼凑起来的。请参考文档了解更多信息。
I am not exactly sure what your problem is, since you don't say whether it did not compile, did not have display or gave a runtime error etc, so I put together a mxml to demonstrate it. The code is mostly cobbled together from the Tree and Menu examples. Please refer to documentation for more details.
<?xml version="1.0" encoding="utf-8"?><mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Menu;
[Bindable]
public var selectedNode:XML;
// Event handler for the Tree control change event.
public function treeChanged(event:Event):void {
selectedNode=mx.controls.Tree(event.target).selectedItem as XML;
}
private var prevMenu:Menu = null
public function showMenu(event:MouseEvent):void
{
if(prevMenu != null)
prevMenu.hide()
var menu:Menu = Menu.createMenu(null, menuData, false);
menu.labelField="@label"
menu.show(event.stageX, event.stageY)
prevMenu = menu
}
]]>
</mx:Script>
<mx:XML id="menuData">
<root>
<menuitem label="copy" eventName="copy"/>
<menuitem label="paste" eventName="paste"/>
</root>
</mx:XML>
<mx:XMLList id="treeData">
<node label="Mail Box">
<node label="Inbox">
<node label="Marketing"/>
<node label="Product Management"/>
<node label="Personal"/>
</node>
<node label="Outbox">
<node label="Professional"/>
<node label="Personal"/>
</node>
<node label="Spam"/>
<node label="Sent"/>
</node>
</mx:XMLList>
<mx:Panel title="Tree Control Example" height="75%" width="75%"
paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
<mx:Label width="100%" color="blue"
text="Select a node in the Tree control."/>
<mx:HDividedBox width="100%" height="100%">
<mx:Tree id="myTree" width="50%" height="100%" labelField="@label"
showRoot="false" dataProvider="{treeData}" change="treeChanged(event)"
rightClick="showMenu(event)"/>
<mx:TextArea height="100%" width="50%"
text="Selected Item: {selectedNode.@label}"/>
</mx:HDividedBox>
</mx:Panel></mx:WindowedApplication>
这篇关于Adobe AIR的 - 添加上下文菜单上单击树节点的权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!