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

add ResetStateMachine

parent ab2f405f
......@@ -13,6 +13,7 @@ type StateMachine struct {
Input *Object
CurrentIndex int
CurrentWord string
Words []string
}
func (s *StateMachine) HandleArrowUp() {
......@@ -39,7 +40,15 @@ func SetStateMachineCurrentIndexAndWord(i int, word string) {
func (s *StateMachine) HandleDefault() {
word := GetInputValue()
ResetStateMachine(word)
}
func ResetStateMachine(word string) {
st.CurrentIndex = 0
st.CurrentWord = word
st.Words = dicmgr.GetSuggestedWords(word, 7)
SetModalWords(GetSuggestedWordsHtml(word, 7))
SetInputValue(word)
}
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
......
......@@ -98,8 +98,7 @@ func FindLongestPrefixWithNonZeroSuggestedWords(word string) string {
func showPossibleWords(word string) {
prefix := FindLongestPrefixWithNonZeroSuggestedWords(word)
SetModalWords(GetSuggestedWordsHtml(prefix, 7))
SetInputValue(prefix)
ResetStateMachine(prefix)
ShowModalInput()
}
......
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