public function createSystrayRootMenu():NativeMenu{
var menu:NativeMenu = new NativeMenu();
var openNativeMenuItem:NativeMenuItem = new NativeMenuItem("打开程序");//生成OPEN菜单项
var exitNativeMenuItem:NativeMenuItem = new NativeMenuItem("退出程序");//同理
openNativeMenuItem.addEventListener(Event.SELECT, undock);
exitNativeMenuItem.addEventListener(Event.SELECT, function(event):void{stage.nativeWindow.close();});//添加EXIT菜单项事件
menu.addItem(openNativeMenuItem);
menu.addItem(new NativeMenuItem("",true));//separator
menu.addItem(exitNativeMenuItem);//将菜单项加入菜单
return menu;
}
private function setSystemTrayProperties():void{
SystemTrayIcon(NativeApplication.nativeApplication .icon).tooltip = "我的常用软件";
SystemTrayIcon(NativeApplication.nativeApplication .icon).addEventListener(MouseEvent.CLICK, undock);
stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING, nwMinimized);
}
private function nwMinimized(displayStateEvent:NativeWindowDisplayStateEvent):void {
if(displayStateEvent.afterDisplayState == NativeWindowDisplayState.MINIMIZED) {
displayStateEvent.preventDefault();//阻止系统默认的关闭窗体事件
dock();//将程序放入托盘
}
}
var menu:NativeMenu = new NativeMenu();
var openNativeMenuItem:NativeMenuItem = new NativeMenuItem("打开程序");//生成OPEN菜单项
var exitNativeMenuItem:NativeMenuItem = new NativeMenuItem("退出程序");//同理
openNativeMenuItem.addEventListener(Event.SELECT, undock);
exitNativeMenuItem.addEventListener(Event.SELECT, function(event):void{stage.nativeWindow.close();});//添加EXIT菜单项事件
menu.addItem(openNativeMenuItem);
menu.addItem(new NativeMenuItem("",true));//separator
menu.addItem(exitNativeMenuItem);//将菜单项加入菜单
return menu;
}
private function setSystemTrayProperties():void{
SystemTrayIcon(NativeApplication.nativeApplication .icon).tooltip = "我的常用软件";
SystemTrayIcon(NativeApplication.nativeApplication .icon).addEventListener(MouseEvent.CLICK, undock);
stage.nativeWindow.addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING, nwMinimized);
}
private function nwMinimized(displayStateEvent:NativeWindowDisplayStateEvent):void {
if(displayStateEvent.afterDisplayState == NativeWindowDisplayState.MINIMIZED) {
displayStateEvent.preventDefault();//阻止系统默认的关闭窗体事件
dock();//将程序放入托盘
}
}