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

handle ArrowUp and ArrowDown event in modal input

parent c8b82f42
......@@ -17,17 +17,28 @@ type StateMachine struct {
}
func (s *StateMachine) HandleArrowUp() {
println("ArrowUp")
s.CurrentIndex--
if s.CurrentIndex == -1 {
s.CurrentIndex = 0
}
s.CurrentWord = s.Words[s.CurrentIndex]
SetInputValue(s.CurrentWord)
}
func (s *StateMachine) HandleArrowDown() {
println("ArrowDown")
s.CurrentIndex++
if s.CurrentIndex == len(s.Words) {
s.CurrentIndex = len(s.Words) - 1
}
s.CurrentWord = s.Words[s.CurrentIndex]
SetInputValue(s.CurrentWord)
}
func (s *StateMachine) HandleEnter() {
word := GetInputValue()
if dicmgr.Lookup(word) {
SetModalTitle(wordLinkHtml(word))
ResetStateMachine(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