加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex自定义右键菜单

发布时间:2020-12-15 05:10:35 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"?s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" applicationComplete="onCreateCo
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
			   applicationComplete="onCreateComplete()"
			   >
	<fx:Declarations>
		<!-- Place non-visual elements (e.g.,services,value objects) here -->
	</fx:Declarations>
	
	<fx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.events.CloseEvent;
			private function onCreateComplete():void {
				
				var item_1:ContextMenuItem = new ContextMenuItem("下面是自定义选项",true,false);
				var item_2:ContextMenuItem = new ContextMenuItem("java",true);
				var item_3:ContextMenuItem = new ContextMenuItem("flex",true);
				var item_4:ContextMenuItem = new ContextMenuItem("oracle");
				
				var myContextMenu:ContextMenu = new ContextMenu();
				
				myContextMenu.hideBuiltInItems();
				
				myContextMenu.customItems.push(item_1);
				myContextMenu.customItems.push(item_2);
				myContextMenu.customItems.push(item_3);
				myContextMenu.customItems.push(item_4);
				
				myContextMenu.addEventListener("menuSelect",menuHandler);
				
				item_1.addEventListener("menuItemSelect",itemHandler);
				item_2.addEventListener("menuItemSelect",itemHandler);
				item_3.addEventListener("menuItemSelect",itemHandler);
				item_4.addEventListener("menuItemSelect",itemHandler);
				
				this.contextMenu = myContextMenu;
			}
			
			private function menuHandler(event:ContextMenuEvent):void {
				//Alert.show("右键菜单弹出...");
			}
			
			private function itemHandler(event:ContextMenuEvent):void {
				Alert.yesLabel = "确定";
				Alert.cancelLabel = "取消";
				Alert.show(event.target.caption,"标题",Alert.YES|Alert.CANCEL,this,myClickHandler);
				
			}
			
			private function myClickHandler(event:CloseEvent):void {
				switch(event.detail) {
					case Alert.YES :
						Alert.show("你点击了确定!!");
						break;
					case Alert.CANCEL :
						Alert.show("你点击了取消!!");
						break;
				}
			}
		]]>

	</fx:Script>
	
</s:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读