The tutorial/documentation for the the Window API ...
# compose-desktop
y
The tutorial/documentation for the the Window API (M4) https://github.com/JetBrains/compose-jb/tree/master/tutorials/Window_API_new talks about handling close for example to ask "Close the document without saving?". If you select Menu/Quit or Command-Q (on macOS) it seems to bypass this mechanism entirely. Is there a way to respond to the "quit" event?
j
This is a general JVM question, not specific to Compose Desktop. You can register a mac quit listener: https://stackoverflow.com/questions/10076104/java-swing-on-a-mac-listening-for-quit-event
y
I am not sure it is a general JVM question. I am not writing a Swing app. I am writing a compose desktop app. I never asked for a menu with a Quit menu item. I never asked for a shortcut (command-q) to terminate the app. Swing is an internal implementation detail which is not surfaced in any of the code I have written so far. I think it should stay that way. It is fine if there is a workaround for the time being, but I really think that this should be handled by compose... something like
Copy code
application(onQuit = {...}) {
  Window(..) { ... }
}
I have created a ticket on github to discuss https://github.com/JetBrains/compose-jb/issues/754. As I mentioned in the ticket the notepad tutorial app suffers from this issue and I think at the minimum, the tutorial pages should explain how to properly deal with this use case.
👍 1
j
Yeah,
application(onQuit)
is not a bad idea. Thanks for the ticket!
👍 1