读书人

flex在树下添加右键菜单和右击选中当前

发布时间: 2012-08-29 08:40:14 作者: rapoo

flex在树上添加右键菜单和右击选中当前项
//增加树右键菜单

public function addTreeMenu():void
{
cm=new ContextMenu();
var newPrj:ContextMenuItem=new ContextMenuItem("创建工程");
var newFol:ContextMenuItem=new ContextMenuItem("创建目录");
var upfiles:ContextMenuItem=new ContextMenuItem("上传文件");
var deploy:ContextMenuItem=new ContextMenuItem("发布");
newPrj.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onNewProjectCommand);
newFol.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onNewFolderCommand);
upfiles.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onImportFilesCommand);
deploy.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onDeployProjectCommand);
cm.hideBuiltInItems();
cm.customItems.push(newPrj);
cm.customItems.push(newFol);
cm.customItems.push(upfiles);
cm.customItems.push(deploy);
treeProject.contextMenu=cm;
}

//右击选中节点

if (evt.mouseTarget is UITextField)
{
treeProject.selectedItem=TreeItemRenderer(UITextField(evt.mouseTarget).owner).data;

}

treeProject为<mx:Tree id="treeProject"

读书人网 >flex

热点推荐