Provide Quit handler for system menu bar
Florian Kirmaier
florian.kirmaier at gmail.com
Tue Sep 13 15:10:47 UTC 2022
Hi Everyone,
In one project, we have to handle the quit-logic for MacOS ourselves,
when the <quit app> menu entry is used.
As background information - this menu entry is set in the
class com.sun.glass.ui.mac.MacApplication.
It's basically hard coded. Currently, in this project, the menu entry
doesn't work in some cases.
My Solution would be:
Provide a method "Platform.setQuiteHandler(Supplier<Boolean>)"
This handler is called when quit <appname> from the menu is called.
If the handler returns true, all windows are closed. Otherwise, nothing
happens.
It would look like the following:
```
/**
* Sets the handler to be called when the application is about to quit.
* Currently, this can only happen on MacOS.
*
* This handler is called, when the user selects
* the "Quit <appname>" from the application menu.
* When the provided handler returns true,
* the application will close all windows.
* If the handler returns false, the application will not quit.
*
* @param The new quit handler.
*/
public static void setQuitHandler(Supplier x) {
...
}
```
I've created a ticket for this topic.
https://bugs.openjdk.org/browse/JDK-8293700
I've got a working version for this change.
According to Kevin Rushforth this need a prior dicussion on the mailing
list.
Any opinion regarding this?
I could provide a pullrequest, if someone is interested.
Florian Kirmaier
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20220913/2bb25f27/attachment.htm>
More information about the openjfx-dev
mailing list