Intercept CMD-Q in OS/X
sufrin opened this issue · 1 comments
sufrin commented
First: thanks to all contributors. JWM does indeed play nicely with Skija (I've been making a UI toolkit for Scala -- soon to go open).
I've been unable to intercept CMD-Q in order to ask the user what she wants to do next (I can, of course, handle window-close requests from the traffic-light). The usual code for installing a quit handler runs without reporting any problem: but cmd-Q just quits the app. I realize there's no reason I should expect the awt.desktop stuff to work; but that's all I have.
/**
* This doesn't fail; but it doesn't prevent CMD-Q from torpedoing an in-flight app.
*/
locally {
if (java.awt.Desktop.isDesktopSupported) {
val desk = java.awt.Desktop.getDesktop
desk.disableSuddenTermination()
if (!desk.isSupported(java.awt.Desktop.Action.APP_QUIT_HANDLER)) println(s"Can't handle Quit")
desk.setQuitHandler(new java.awt.desktop.QuitHandler {
def handleQuitRequestWith(e: QuitEvent, response: QuitResponse): Unit = {
println(s"Quit: $e")
if (false) response.performQuit() else response.cancelQuit()
}
})
} else println("Desktop not supported")
tonsky commented
Yeah there needs to be a special handler for that which we don’t have yet