10 Replies Latest reply on Feb 5, 2009 11:10 AM by

    Minimize to system tray

      I am developing a small HTML based AIR app. So there is only one HTML file in the whole app. What is the simplest way to implement minimize to system tray?

      I checked out: http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7dcc. html

      But a sample code/explaination would be good.


        • 1. Re: Minimize to system tray
          Level 7
          JSayani wrote:
          > I am developing a small HTML based AIR app. So there is only one HTML file in
          > the whole app. What is the simplest way to implement minimize to system tray?
          >
          > I checked out:
          > http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666a
          > de46-7dcc.html
          >
          > But a sample code/explaination would be good.

          I haven't checked out the code, but there is a JavaScript AIR samples application as well as source code:
          http://code.google.com/p/jsairsamples/
          .air file to install from the Downloads page. You can get the source on the Browse page via SVN, or individual files from the Browse section. One of the samples has various window related functions, including minimizing.

          A little more about this project:
          http://blog.kevinhoyt.org/2009/01/17/javascript-air-samples-updated-and-more/


          --
          Danilo Celic
          | http://blog.extensioneering.com/
          | WebAssist Extensioneer
          | Adobe Community Expert
          • 2. Re: Minimize to system tray
            Level 7
            danilocelic AdobeCommunityExpert wrote:
            > .air file to install from the Downloads page. You can get the source on
            > the Browse page via SVN, or individual files from the Browse section.

            Or of course, as the AIR install files are readily viewable, you can browse the source files in the install location. For at the default install location:
            C:\Program Files\AIR Samples\


            --
            Danilo Celic
            | http://blog.extensioneering.com/
            | WebAssist Extensioneer
            | Adobe Community Expert
            1 person found this helpful
            • 3. Minimize to system tray
              Thank you for your responses. I have managed to create a system tray icon when the application loads and upon right-click on the icon, I have added a menu.

              However, it would be great if you let me know how to assign actions to the clicks. Like an About screen when clicking on "About" and opening a URL in the browser, when clicking on "Homepage".

              Thanks.

              • 4. Re: Minimize to system tray
                Level 7
                JSayani wrote:
                > Thank you for our responses. I have managed to create a system tray icon when
                > the application loads and upon right-click on the icon, I have added a menu.
                >
                > However, it would be great if you let me know how to assign actions to the
                > clicks. Like an About screen when clicking on "About" and opening a URL in the
                > browser, when clicking on "Homepage".

                Sorry, you'll need to ask someone else as I've not done much AIR development yet. As your current question doesn't directly relate to the minimizing of a window, perhaps make a new post for question to draw other's attention to it.


                --
                Danilo Celic
                | http://blog.extensioneering.com/
                | WebAssist Extensioneer
                | Adobe Community Expert
                1 person found this helpful
                • 5. Re: Minimize to system tray
                  Ok. I will create a new thread for it.

                  But, now I have only created the system tray icon. How do I make the app minimize to tray when it is minimized and make it launch back on system tray icon click ?


                  • 6. Re: Minimize to system tray
                    Level 7
                    JSayani wrote:
                    > Ok. I will create a new thread for it.
                    >
                    > But, now I have only created the system tray icon. How do I make the app
                    > minimize to tray when it is minimized and make it launch back on system tray
                    > icon click ?

                    Again, I'm sorry, from me its still the same answer, I've not done much with AIR, so you should probably ask this particular question in it's own thread as well.


                    --
                    Danilo Celic
                    | http://blog.extensioneering.com/
                    | WebAssist Extensioneer
                    | Adobe Community Expert
                    • 7. Re: Minimize to system tray
                      Joe ... Ward Level 4
                      There's really no "minimize to tray" function. You simply hide the window (or windows) in response to some event in your application (such as a displayStateChanging event) by setting the NativeWindow visible property to false. To restore your window, set the NativeWindow visible property back to true in response to a mouse click event dispatched by the SystemTrayIcon object.

                      As to your earlier question in the thread about menus, each menu item will dispatch a select event when the user selects it. You add a listener to the NativeMenuItem object that calls the appropriate function. In other words:

                      menuItem.addEventListener( air.Event.SELECT, menuFunction );

                      private function menuFunction( event)
                      {
                      //...
                      }
                      1 person found this helpful
                      • 8. Re: Minimize to system tray
                        Thanks. Now I know how to add action statements. However, what code do I write to hide the windows and show the window ?

                        Also, how to I refer to the minimize button ?

                        • 9. Re: Minimize to system tray
                          jbenson@oper8 Level 2
                          You should check out:

                          http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7e08. html

                          //hide a window
                          window.nativeWindow.visible = false;

                          //show a previously hidden window
                          window.nativeWindow.visible = true;

                          /* i tend to activate here because I'm not always sure what state the window is in, your choice etc*/
                          window.nativeWindow.activate();

                          //minimize / maximize
                          window.nativeWindow.minimize();
                          window.nativeWindow.maximize();

                          Hope that helps


                          • 10. Re: Minimize to system tray
                            Thanks man. You solved all my problems!!