5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-10 22:19:46 +08:00
wails/v3/examples/show-macos-toolbar/main.go
2025-04-25 20:51:34 +10:00

57 lines
1.6 KiB
Go

package main
import (
_ "embed"
"log"
"runtime"
"github.com/wailsapp/wails/v3/pkg/application"
)
func main() {
app := application.New(application.Options{
Name: "Show macOS Toolbar",
Description: "A demo of the ShowToolbarWhenFullscreen option",
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
})
// Create window
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Toolbar hidden (default behaviour)",
HTML: "<html><body><h1>Switch this window to fullscreen: the toolbar will be hidden</h1></body></html>",
CSS: `body { background-color: blue; color: white; height: 100vh; display: flex; justify-content: center; align-items: center; }`,
Mac: application.MacWindow{
TitleBar: application.MacTitleBar{
UseToolbar: true,
HideToolbarSeparator: true,
},
},
})
// Create window
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Toolbar visible",
HTML: "<html><body><h1>Switch this window to fullscreen: the toolbar will stay visible</h1></body></html>",
CSS: `body { background-color: red; color: white; height: 100vh; display: flex; justify-content: center; align-items: center; }`,
Mac: application.MacWindow{
TitleBar: application.MacTitleBar{
UseToolbar: true,
HideToolbarSeparator: true,
ShowToolbarWhenFullscreen: true,
},
},
})
if runtime.GOOS != "darwin" {
println("Warning: This example will only run correctly on macOS.")
}
err := app.Run()
if err != nil {
log.Fatal(err)
}
}