aboutsummaryrefslogtreecommitdiff
path: root/go/ui/textInput_wasm.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/ui/textInput_wasm.go')
-rw-r--r--go/ui/textInput_wasm.go49
1 files changed, 0 insertions, 49 deletions
diff --git a/go/ui/textInput_wasm.go b/go/ui/textInput_wasm.go
deleted file mode 100644
index 0ced3ac4..00000000
--- a/go/ui/textInput_wasm.go
+++ /dev/null
@@ -1,49 +0,0 @@
-package ui
-
-import (
- "log"
- "syscall/js"
- "unicode/utf8"
-)
-
-// rmueller's version from:
-// ://stackoverflow.com/questions/1752414/how-to-reverse-a-string-in-go?page=1&tab=scoredesc#tab-top
-func reverseString(s string) string {
- size := len(s)
- buf := make([]byte, size)
- for start := 0; start < size; {
- r, n := utf8.DecodeRuneInString(s[start:])
- start += n
- utf8.EncodeRune(buf[size-start:], r)
- }
- return string(buf)
-}
-
-func (ti *TextInput) Focus(focus bool) {
- ti.focused = focus
- log.Printf("%v set focus: %v\n", ti, focus)
- if focus {
- d := js.Global().Get("document")
- i := d.Call("getElementById", "hiddenInput")
- // i.Call("focus", map[string]any{"preventScroll": true, "focusVisible": false})
- i.Call("focus")
- log.Println("open keyboard")
-
- log.Printf("set hidden input value to %s", ti.Text())
- // i.Set("value", ti.Text())
- i.Set("value", reverseString(ti.Text()))
- }
-}
-
-func (ti *TextInput) Update() error {
- if ti.focused {
- d := js.Global().Get("document")
- i := d.Call("getElementById", "hiddenInput")
- // t := i.Get("value").String()
- t := reverseString(i.Get("value").String())
- ti.SetInput(t)
- }
- return nil
-}
-
-func (*TextInput) IsUpdatable() bool { return true }