5 Replies Latest reply on Apr 17, 2010 2:32 AM by kkm19

    Two quick AIR(AJAX) questions.

    Beau West
      I've been working on developing an AIR interface for a web app that I've also been developing. It is necessary for my AIR app to minimize to the system tray (on Windows) so it's out of the way.

      I already have that functionality in place, however, I am having trouble finding a solution to capture the windows chrome minimize event, suppress it, and run my own minimize function.

      I am also wanting a single (or double, doesn't matter) click on the tray icon to restore the window. Again, I have the functionality in place, but am having trouble capturing the click event on the tray icon.

      I'm sure I'm just missing something about how AIR uses events, so if y'all would be so kind as to point me in the correct direction, I would appreciate it! Thanks!
      -Beau
        • 1. Re: Two quick AIR(AJAX) questions.
          Joe ... Ward Level 4
          For the window minimize event:

          window.nativeWindow.addEventListener(air.NativeWindow.MINIMIZING, yourMinimizeFunction);

          function yourMinimizeFunction(event){
          event.preventDefault();
          //...
          }

          For the Icon click:
          if(air.NativeApplication.supportsSystemTrayIcon){
          air.NativeApplication.nativeApplication.icon.addEventListener("click", clickHandler);
          } else if(air.NativeApplication.supportsDockIcon){
          air.NativeApplication.nativeApplication.addEventListener("invoke", clickHandler);
          }

          Note that the events aren't symmetrical between Windows and Mac. Windows gives you mouse events, the Mac gives you an invoke event. Also, this code has not been checked, there may be typos, etc.
          • 2. Re: Two quick AIR(AJAX) questions.
            Beau West Level 1
            Brilliant. The second tidbit worked great (click on the task icon). However the first one, I still am having issues with. When using your code directly, here is the message I receive:

            TypeError: Error #2007: Parameter type must be non-null.
            undefined at app:/air.html : 17

            I've tried several variations built on that, but can't get any to work. Thanks again for your help, any more clues as to capturing the minimize event?
            • 3. Re: Two quick AIR(AJAX) questions.
              Joe ... Ward Level 4
              Sorry, the event is air.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGING. The event gives you a NativeWindowDisplayStateEvent object which has beforeDisplayState and afterDisplayState properties that tell you what will change.
              • 4. Re: Two quick AIR(AJAX) questions.
                Beau West Level 1
                Thanks! I was able to figure it out last night, the event I used was

                window.nativeWindow.addEventListener(air.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANG E, onMinimize);

                Again, thanks for your help.
                • 5. Re: Two quick AIR(AJAX) questions.
                  kkm19 Level 1

                  thaanks

                   

                  window.nativeWindow.addEventListener(air.NativeWindowDisplayStateEvent.DISPLAY_S  TATE_CHANGE, onMinimize);