internal/ui: refactoring: reduce theUI

This commit is contained in:
Hajime Hoshi 2023-10-15 17:02:15 +09:00
parent 83a4133577
commit 0378230b3e
4 changed files with 10 additions and 10 deletions

View File

@ -78,14 +78,14 @@ func (t *textInput) init() {
e.Call("preventDefault") e.Call("preventDefault")
} }
if !e.Get("isComposing").Bool() { if !e.Get("isComposing").Bool() {
ui.UpdateInputFromEvent(e) ui.Get().UpdateInputFromEvent(e)
} }
return nil return nil
})) }))
t.textareaElement.Call("addEventListener", "keyup", js.FuncOf(func(this js.Value, args []js.Value) any { t.textareaElement.Call("addEventListener", "keyup", js.FuncOf(func(this js.Value, args []js.Value) any {
e := args[0] e := args[0]
if !e.Get("isComposing").Bool() { if !e.Get("isComposing").Bool() {
ui.UpdateInputFromEvent(e) ui.Get().UpdateInputFromEvent(e)
} }
return nil return nil
})) }))

View File

@ -223,8 +223,8 @@ func (u *UserInterface) KeyName(key Key) string {
return n.String() return n.String()
} }
func UpdateInputFromEvent(e js.Value) { func (u *UserInterface) UpdateInputFromEvent(e js.Value) {
theUI.updateInputFromEvent(e) u.updateInputFromEvent(e)
} }
func (u *UserInterface) saveCursorPosition() { func (u *UserInterface) saveCursorPosition() {

View File

@ -65,12 +65,12 @@ func (g *graphicsDriverCreatorImpl) newMetal() (graphicsdriver.Graphics, error)
return metal.NewGraphics() return metal.NewGraphics()
} }
func SetUIView(uiview uintptr) error { func (u *UserInterface) SetUIView(uiview uintptr) error {
return theUI.setUIView(uiview) return u.setUIView(uiview)
} }
func IsGL() (bool, error) { func (u *UserInterface) IsGL() (bool, error) {
return theUI.isGL() return u.isGL()
} }
func (u *UserInterface) setUIView(uiview uintptr) error { func (u *UserInterface) setUIView(uiview uintptr) error {

View File

@ -19,9 +19,9 @@ import (
) )
func SetUIView(uiview int64) error { func SetUIView(uiview int64) error {
return ui.SetUIView(uintptr(uiview)) return ui.Get().SetUIView(uintptr(uiview))
} }
func IsGL() (bool, error) { func IsGL() (bool, error) {
return ui.IsGL() return ui.Get().IsGL()
} }