forked from wailsapp/wails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darwin: add event ApplicationShouldHandleReopen (wailsapp#2991)
* darwin: add ApplicationShouldHandleReopen * docs: update changelog with mr id * events: update id * feat: always return true * Merge v3-alpha and regenerate events * darwin: allow pass nsdirectory to processApplicationEvent --------- Co-authored-by: Lea Anthony <[email protected]>
- Loading branch information
1 parent
d1c3f8a
commit f8250fb
Showing
10 changed files
with
639 additions
and
504 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package main | ||
|
||
import ( | ||
_ "embed" | ||
"log" | ||
"runtime" | ||
|
||
"github.com/wailsapp/wails/v3/pkg/application" | ||
"github.com/wailsapp/wails/v3/pkg/icons" | ||
"github.com/wailsapp/wails/v3/pkg/events" | ||
) | ||
|
||
func main() { | ||
app := application.New(application.Options{ | ||
Name: "Hide Window Demo", | ||
Description: "A test of Hidden window and display it", | ||
Assets: application.AlphaAssets, | ||
Mac: application.MacOptions{ | ||
// ActivationPolicy: application.ActivationPolicyAccessory, | ||
ApplicationShouldTerminateAfterLastWindowClosed: false, | ||
}, | ||
}) | ||
|
||
systemTray := app.NewSystemTray() | ||
|
||
window := app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ | ||
Width: 500, | ||
Height: 800, | ||
Frameless: false, | ||
AlwaysOnTop: false, | ||
Hidden: false, | ||
DisableResize: false, | ||
ShouldClose: func(window *application.WebviewWindow) bool { | ||
println("close") | ||
window.Hide() | ||
return false | ||
}, | ||
Windows: application.WindowsWindow{ | ||
HiddenOnTaskbar: true, | ||
}, | ||
}) | ||
|
||
if runtime.GOOS == "darwin" { | ||
systemTray.SetTemplateIcon(icons.SystrayMacTemplate) | ||
} | ||
|
||
|
||
// Click Dock icon tigger application show | ||
app.On(events.Mac.ApplicationShouldHandleReopen, func(event *application.Event) { | ||
println("reopen") | ||
window.Show() | ||
}) | ||
|
||
myMenu := app.NewMenu() | ||
myMenu.Add("Show").OnClick(func(ctx *application.Context) { | ||
window.Show() | ||
}) | ||
|
||
myMenu.Add("Quit").OnClick(func(ctx *application.Context) { | ||
app.Quit() | ||
}) | ||
|
||
systemTray.SetMenu(myMenu) | ||
systemTray.OnClick(func() { | ||
app.CurrentWindow().Show() | ||
}) | ||
|
||
err := app.Run() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} |
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
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
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
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
Oops, something went wrong.