首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

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

2012-08-29 
flex在树上添加右键菜单和右击选中当前项//增加树右键菜单 public function addTreeMenu():void{ cmnew C

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"

热点排行