Add option to prevent application shutdown

This update allows the application shutdown to be cancelled. It implements the shouldQuit function, which can prevent the application from quitting if it returns false. Additional checks have been added to ensure cleanup and quit processes are performed only if required. The darwin delegate and linux and windows applications were modified to include this new functionality.
This commit is contained in:
Lea Anthony
2024-01-17 20:45:30 +11:00
parent ab22ea1f27
commit 861ddea1b2
10 changed files with 66 additions and 18 deletions
+6 -3
View File
@@ -21,7 +21,7 @@ func main() {
Description: "A demo of the WebviewWindow API",
Assets: application.AlphaAssets,
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: false,
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
app.On(events.Mac.ApplicationDidFinishLaunching, func(event *application.Event) {
@@ -40,8 +40,11 @@ func main() {
// Create a custom menu
menu := app.NewMenu()
menu.AddRole(application.AppMenu)
if runtime.GOOS == "darwin" {
menu.AddRole(application.AppMenu)
} else {
menu.AddRole(application.FileMenu)
}
windowCounter := 1
// Let's make a "Demo" menu