1. #1
    Ext User
    Join Date
    Jul 2009
    Posts
    1
    Vote Rating
    0
    Greg-Mega is on a distinguished road

      0  

    Default Programmatically minimizing to tray

    Programmatically minimizing to tray


    Trying to work out how to programatically minimize my AIR application to the system tray.

    I've tried:

    Code:
    window.nativewindow.minimize();
    But that just minimizes and doesn't go to the system tray as it does when I click the minimize button... surely I'm just overlooking something here?

  2. #2
    Ext User
    Join Date
    Jan 2009
    Posts
    44
    Vote Rating
    0
    wmazza is on a distinguished road

      0  

    Default


    hey Greg,

    To minimize air applications to the system tray, you have to create a tray icon. Here is a quick example:

    Code:
    // Check if we can create a System Tray Icon
    if (air.NativeApplication.supportsSystemTrayIcon) {
        // By default, there is no icon for the system tray, so let's load one!
        var iconLoad = new air.Loader();
            iconLoad.contentLoaderInfo.addEventListener(air.Event.COMPLETE,function(evt){
                air.NativeApplication.nativeApplication.icon.bitmaps = [evt.target.content.bitmapData];
            });
            iconLoad.load(new air.URLRequest("/resources/icons/MyAppIcon_16x16.png"));
        
        // Assign tooltip to icon
        air.NativeApplication.nativeApplication.icon.tooltip = "My App";
        
        // Create a tray menu
        var trayMenu = new air.NativeMenu();
        
        var tmOpen = new air.NativeMenuItem("Show My App");
            tmOpen.addEventListener(air.Event.SELECT,function() {
                Ext.air.NativeWindowManager.get('mainWin').activate();
            });
        
        var tmSeperator= new air.NativeMenuItem("-", true);
        
        var tmExit = new air.NativeMenuItem("Exit");
            tmExit.addEventListener(air.Event.SELECT,applicationExit);
        
        trayMenu.addItem(tmOpen);
        trayMenu.addItem(tmSeperator);
        trayMenu.addItem(tmExit);
        
        // Assign the menu to the icon
        air.NativeApplication.nativeApplication.icon.menu = trayMenu;
    }
    
    function applicationExit(){ 
        var exitingEvent = new air.Event(air.Event.EXITING, false, true);
        air.NativeApplication.nativeApplication.dispatchEvent(exitingEvent);
        if (!exitingEvent.isDefaultPrevented()) air.NativeApplication.nativeApplication.exit();
    };
    Above code works for Windows machines. Make sure to create one for Macs as well! More details can be found on the Adobe AIR documentation site:
    (AIR 1.5) http://help.adobe.com/en_US/AIR/1.5/...de46-7dcc.html
    (AIR 1.1) http://help.adobe.com/en_US/AIR/1.1/...de46-7dcc.html

  3. #3
    Ext User dudecool's Avatar
    Join Date
    Nov 2007
    Location
    Bangalore, Karnataka, India
    Posts
    26
    Vote Rating
    0
    dudecool is on a distinguished road

      0  

    Default


    Hi,
    I guess we cannot minimize the window into tray but we can simulate it by using the below code
    Code:
    window.nativeWindow.minimize();
    window.nativeWindow.visible = false;
    We can just say
    Code:
    window.nativeWindow.visible = false;
    but when minimized os take care of freeing up memory, for me a 45mb application becoame 15mb.

    In the above code there is a small addition just after setting the tooltip
    Code:
    air.NativeApplication.nativeApplication.icon.addEventListener("click", function(){
        if (!window.nativeWindow.visible) {
    	window.nativeWindow.restore();
    	window.nativeWindow.visible = true;
        }
        window.nativeWindow.alwaysInFront = true;
        window.nativeWindow.alwaysInFront = false;
        air.NativeApplication.nativeApplication.activate(window.nativeWindow);
    });
    hope this help! if anyone find a better way of doing it let me know
    Regards,
    Jayaveer.B
    http://gallery.jayaveer.com/

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar