5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-05 07:00:39 +08:00
wails/v3/examples/raw-message/main.go
2024-06-08 20:43:24 +10:00

45 lines
1.0 KiB
Go

package main
import (
"embed"
_ "embed"
"github.com/wailsapp/wails/v3/pkg/application"
"log"
)
//go:embed assets
var assets embed.FS
func main() {
app := application.New(application.Options{
Name: "Raw Message Demo",
Description: "A demo of sending raw messages from the frontend",
Assets: application.AssetOptions{
Handler: application.BundledAssetFileServer(assets),
},
Mac: application.MacOptions{
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
RawMessageHandler: func(window application.Window, message string) {
println("Raw message received from Window '" + window.Name() + "' with message: " + message)
},
})
app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
Title: "Window 1",
Name: "Window 1",
Mac: application.MacWindow{
Backdrop: application.MacBackdropTranslucent,
TitleBar: application.MacTitleBarHiddenInsetUnified,
InvisibleTitleBarHeight: 50,
},
})
err := app.Run()
if err != nil {
log.Fatal(err.Error())
}
}