Commit ce700b97 authored by Siong-Ui Te's avatar Siong-Ui Te

update input fuc

parent 73f4f828
package main
import (
"strings"
. "github.com/siongui/godom"
"github.com/siongui/gopalilib/lib/dicmgr"
)
var input *Object
......@@ -14,16 +17,31 @@ func inputKeyupEventHandler(key string) {
case "ArrowDown", "Down":
println("ArrowDown")
case "Enter":
println("Enter")
word := GetInputValue()
if dicmgr.Lookup(word) {
SetModalTitle(wordLinkHtml(word))
go showWordDefinitionInModal(word)
}
default:
println("default")
}
}
func FocusInput() {
input.Focus()
}
func SetInputValue(v string) {
input.SetValue(v)
}
func GetInputValue() string {
s := input.Value()
s = strings.TrimSpace(s)
s = strings.ToLower(s)
return s
}
func SetupModalInput(selector string) {
input = Document.QuerySelector(selector)
input.AddEventListener("keyup", func(e Event) {
......
......@@ -105,6 +105,7 @@ func showPossibleWords(word string) {
}
func wordClickedHandler(word string) {
FocusInput()
if dicmgr.Lookup(word) {
SetModalTitle(wordLinkHtml(word))
go showWordDefinitionInModal(word)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment