Created
June 3, 2011 11:15
-
-
Save peterblazejewicz/1006205 to your computer and use it in GitHub Desktop.
prevent CMD+Q default action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mdm.Application; | |
import mx.controls.Alert; | |
import mx.events.CloseEvent; | |
// | |
// when application starts | |
// enable exit handler | |
// and route exit event to custom handler | |
// to get user action | |
// | |
private function initApp():void | |
{ | |
mdm.Application.enableExitHandler(); | |
mdm.Application.onAppExit = myExitHandler; | |
}; | |
// | |
// called when application is to quit | |
// e.g. as results of CMD+Q | |
// | |
private function myExitHandler():void | |
{ | |
mx.controls.Alert.show("Do you want to quit?", "EXIT", Alert.YES | Alert.CANCEL, this, closeHandler); | |
}; | |
// | |
// if YES then exit | |
// | |
private function closeHandler(event:CloseEvent):void | |
{ | |
if(event.detail == Alert.YES) | |
{ | |
mdm.Application.exit(); | |
} else | |
{ | |
// nothing | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment