5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-04 14:49:27 +08:00
wails/v3/examples/show-macos-toolbar/main.go
Fabio Massaioli 7e687750b2
[v3] Add option for showing the toolbar in fullscreen mode on macOS (#3282)
* Add option for showing the toolbar in fullscreen mode on macOS

* Add an example demonstrating the ShowToolbarWhenFullscreen option

* Update docs

* Add changelog entry

* Run go mod tidy
2024-03-02 20:10:25 +11:00

52 lines
1.5 KiB
Go

package main
import (
_ "embed"
"log"
"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,
},
},
})
err := app.Run()
if err != nil {
log.Fatal(err)
}
}