Another fix for InputField. Fixes #176, resolves #177

This commit is contained in:
Oliver 2018-11-05 11:09:49 +01:00
parent 1dd674a1b9
commit 61a4cf388a
1 changed files with 6 additions and 10 deletions

View File

@ -374,12 +374,7 @@ func (i *InputField) InputHandler() func(event *tcell.EventKey, setFocus func(p
// Process key event.
switch key := event.Key(); key {
case tcell.KeyRune: // Regular character.
modifiers := event.Modifiers()
if modifiers == tcell.ModNone {
if !add(event.Rune()) {
break
}
} else if modifiers&tcell.ModAlt > 0 {
if event.Modifiers()&tcell.ModAlt > 0 {
// We accept some Alt- key combinations.
switch event.Rune() {
case 'a': // Home.
@ -390,12 +385,13 @@ func (i *InputField) InputHandler() func(event *tcell.EventKey, setFocus func(p
moveWordLeft()
case 'f': // Move word right.
moveWordRight()
default: // Ignore Alt modifier for other keys.
}
} else {
// Other keys are simply accepted as regular characters.
if !add(event.Rune()) {
break
}
}
}
case tcell.KeyCtrlU: // Delete all.
i.text = ""
i.cursorPos = 0