2 Replies Latest reply on Mar 18, 2009 12:09 PM by ethanmos

    preventdefault of window closing event

      if i prevent a window from closing using the preventdefault method of the closing event, my app no longer quits when a user either enters command + q or quits from the menu. has anyone run into this problem?

      what i'm trying to do is prevent the window object from being destroyed. im stopping the closing event and setting the visible property to false. is there a better way to do this rather than stopping the event.
        • 1. Re: preventdefault of window closing event
          Joe ... Ward Level 4
          On the Mac, you could listen for the exiting event and then close the window programatically. I'm not sure how you will handle this on Windows or Linux since you normally quit the app by closing its main or last window.
          • 2. Re: preventdefault of window closing event
            Level 1
            this is exactly what i was looking for, thanks!!!

            for others, this is what i did...

            NativeApplication.nativeApplication.addEventListener(Event.EXITING, applicationExitHandler,false,0,true);

            private function applicationExitHandler(event:Event):void {

            in the main app i handle the close event with:

            private function onClose(event:Event=null):void {
            for(var i:int = NativeApplication.nativeApplication.openedWindows.length - 1; i >= 0; --i) {
            NativeWindow(NativeApplication.nativeApplication.openedWindows ).close();


            that should take care of it