3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.air.SystemTray = function(){
\r
9 var app = air.NativeApplication.nativeApplication;
\r
10 var icon, isWindows = false, bitmaps;
\r
13 if(air.NativeApplication.supportsSystemTrayIcon) {
\r
19 if(air.NativeApplication.supportsDockIcon) {
\r
25 setIcon : function(icon, tooltip, initWithIcon){
\r
26 if(!icon){ // not supported OS
\r
29 var loader = new air.Loader();
\r
30 loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, function(e){
\r
31 bitmaps = new runtime.Array(e.target.content.bitmapData);
\r
33 icon.bitmaps = bitmaps;
\r
36 loader.load(new air.URLRequest(icon));
\r
37 if(tooltip && air.NativeApplication.supportsSystemTrayIcon) {
\r
38 app.icon.tooltip = tooltip;
\r
42 bounce : function(priority){
\r
43 icon.bounce(priority);
\r
46 on : function(eventName, fn, scope){
\r
47 icon.addEventListener(eventName, function(){
\r
48 fn.apply(scope || this, arguments);
\r
52 hideIcon : function(){
\r
53 if(!icon){ // not supported OS
\r
59 showIcon : function(){
\r
60 if(!icon){ // not supported OS
\r
63 icon.bitmaps = bitmaps;
\r
66 setMenu: function(actions, _parentMenu){
\r
67 if(!icon){ // not supported OS
\r
70 var menu = new air.NativeMenu();
\r
72 for (var i = 0, len = actions.length; i < len; i++) {
\r
75 menu.addItem(new air.NativeMenuItem("", true));
\r
77 var item = menu.addItem(Ext.air.MenuItem(a));
\r
78 if(a.menu || (a.initialConfig && a.initialConfig.menu)){
\r
79 item.submenu = Ext.air.SystemTray.setMenu(a.menu || a.initialConfig.menu, menu);
\r