Support Window aliases

This commit is contained in:
Lea Anthony 2022-12-11 14:39:53 +11:00
commit ddb2f63f7b
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
4 changed files with 12 additions and 2 deletions

2
exp/.gitignore vendored
View file

@ -1,2 +1,2 @@
examples/basic/basic
examples/kitchensink/kitchensink
cmd/wails/wails

View file

@ -22,7 +22,8 @@ type App struct {
options *options.Application
applicationEventListeners map[uint][]func()
windows map[uint]*Window
windows map[uint]*Window
windowAliases map[string]uint
// Running
running bool
@ -47,6 +48,12 @@ func (a *App) NewWindow(options *options.Window) *Window {
a.windows = make(map[uint]*Window)
}
a.windows[id] = newWindow
if options.Alias != "" {
if a.windowAliases == nil {
a.windowAliases = make(map[string]uint)
}
a.windowAliases[options.Alias] = id
}
if a.running {
newWindow.Run()
}

View file

@ -48,6 +48,7 @@ func getWindowID() uint {
}
func NewWindow(options *options.Window) *Window {
return &Window{
id: getWindowID(),
options: options,

View file

@ -10,6 +10,8 @@ const (
)
type Window struct {
// Alias is a human-readable name for the window. This can be used to reference the window in the frontend.
Alias string
Title string
Width, Height int
AlwaysOnTop bool