ui: Add SetWindowTitle

Fixes #595
This commit is contained in:
Hajime Hoshi 2018-05-02 19:09:03 +09:00
parent 0e19aa558a
commit 9efccea31c
4 changed files with 28 additions and 0 deletions

View File

@ -311,6 +311,16 @@ func IsRunnableInBackground() bool {
return currentUI.isRunnableInBackground() return currentUI.isRunnableInBackground()
} }
func SetWindowTitle(title string) {
if !currentUI.isRunning() {
return
}
_ = currentUI.runOnMainThread(func() error {
currentUI.window.SetTitle(title)
return nil
})
}
func SetWindowIcon(iconImages []image.Image) { func SetWindowIcon(iconImages []image.Image) {
if !currentUI.isRunning() { if !currentUI.isRunning() {
currentUI.setInitIconImages(iconImages) currentUI.setInitIconImages(iconImages)

View File

@ -112,6 +112,11 @@ func SetCursorVisible(visible bool) {
} }
} }
func SetWindowTitle(title string) {
doc := js.Global.Get("document")
doc.Set("title", title)
}
func SetWindowIcon(iconImages []image.Image) { func SetWindowIcon(iconImages []image.Image) {
// Do nothing // Do nothing
} }

View File

@ -360,6 +360,10 @@ func SetRunnableInBackground(runnableInBackground bool) {
// Do nothing // Do nothing
} }
func SetWindowTitle(title string) {
// Do nothing
}
func SetWindowIcon(iconImages []image.Image) { func SetWindowIcon(iconImages []image.Image) {
// Do nothing // Do nothing
} }

9
run.go
View File

@ -428,6 +428,15 @@ func SetRunnableInBackground(runnableInBackground bool) {
ui.SetRunnableInBackground(runnableInBackground) ui.SetRunnableInBackground(runnableInBackground)
} }
// SetWindowTitle sets the title of the window.
//
// SetWindowTitle does nothing on mobiles.
//
// SetWindowTitle is concurrent-safe.
func SetWindowTitle(title string) {
ui.SetWindowTitle(title)
}
// SetWindowIcon sets the icon of the game window. // SetWindowIcon sets the icon of the game window.
// //
// If len(iconImages) is 0, SetWindowIcon reverts the icon to the default one. // If len(iconImages) is 0, SetWindowIcon reverts the icon to the default one.