Tag Archives: Flex右键

Flex中使用ContextMenu - 添加,动态改变, 响应.

AIR Only: AIR: 通过监听ContextMenuEvent.MENU_SELECT事件 动态改变菜单内容

\ 这里是通用的:

		_menu = new ContextMenu();
		_menuAddTopOU = new ContextMenuItem(RM.getString(BUNDLE_OUSETUP, "ous.menu.addTopOU"));
		_menuAdd = new ContextMenuItem(null, true);
		_menuEdit = new ContextMenuItem(null);
		_menuRemove = new ContextMenuItem(null);

		_menu.customItems.push(_menuAddTopOU);
		_menu.customItems.push(_menuAdd);
		_menu.customItems.push(_menuEdit);
		_menu.customItems.push(_menuRemove);
		_menu.addEventListener(ContextMenuEvent.MENU_SELECT, onMenuSelected);
		_menu.addEventListener(Event.SELECT, onMenuItemSelected);

		_treeOUs.contextMenu = _menu;

	// Menu打开后动态改变菜单内容
	private function onMenuSelected(event:ContextMenuEvent):void {
		...
		_menuAddTopOU.enabled = !tempNew; // add Top ou
		_menuAdd.enabled = (_treeOUs.selectedItem != null) && (!_editorOU.editable);	// add ou
		if(_menuAdd.enabled) {
			_menuAdd.label = RM.getString(BUNDLE_OUSETUP, "ous.menu.add", [currentOU.nameFullLocalized]);
		}else {
			_menuAdd.label = RM.getString(BUNDLE_OUSETUP, "ous.menu.selectOneFirst");
		}

		..
	}

	// 选中Menu中某item后响应
	private function onMenuItemSelected(event:Event):void {
		if(event.target == _menuAddTopOU) { // 增加顶级部门
			onAction(_actionAddTopOU, null);
		}else ...
	}
Posted in ActionScript, Flex | Tagged , , | Leave a comment

AIR: 通过监听ContextMenuEvent.MENU_SELECT事件 动态改变菜单内容

某Tree上的menu
_menu = new NativeMenu();
_menuAddTopOU = new NativeMenuItem("Add Top OU");
_menuAdd = new NativeMenuItem("Selcet one

Posted in ActionScript | Tagged , , , , , | Leave a comment

使用ActionScript建立DataGrid, 添加右键, 增加列, 并设定列的ItemRenderer

很多时候为了获得对组件的灵活控制, 不得不放弃MXML, 直接使用ActionScript.

Posted in ActionScript | Tagged , , , , | 3 Comments

AIR中通过右键直接选定基于LIST容器[DataGrid, List, Tree等]的数据 – Select List item with mouse right-click

在很多情况下, 我们在DataGrid, List, Tree等容器中使用右键, 进行如修改, 删除 某行的操作. 问题是如果该容器初始状态下直接进行右键点击时, 并不能选定任何数据. 通过监听右键菜单SELECT事件, 获取到当前右键所击位置的Index, 并将之赋值给DataGrid或其他容器的SelectIndex, 完成点击操作

Posted in AIR | Tagged , , , , , | 2 Comments