mirror of https://github.com/rivo/tview.git
Hitting Escape on a drop-down selection resets it.
This commit is contained in:
parent
c33dd0cf8e
commit
768070ef7b
|
@ -354,6 +354,7 @@ func (d *DropDown) InputHandler() func(event *tcell.EventKey, setFocus func(p Pr
|
||||||
|
|
||||||
// Hand control over to the list.
|
// Hand control over to the list.
|
||||||
d.open = true
|
d.open = true
|
||||||
|
optionBefore := d.currentOption
|
||||||
d.list.SetSelectedFunc(func(index int, mainText, secondaryText string, shortcut rune) {
|
d.list.SetSelectedFunc(func(index int, mainText, secondaryText string, shortcut rune) {
|
||||||
// An option was selected. Close the list again.
|
// An option was selected. Close the list again.
|
||||||
d.open = false
|
d.open = false
|
||||||
|
@ -374,6 +375,10 @@ func (d *DropDown) InputHandler() func(event *tcell.EventKey, setFocus func(p Pr
|
||||||
d.prefix = string(r[:len(r)-1])
|
d.prefix = string(r[:len(r)-1])
|
||||||
}
|
}
|
||||||
evalPrefix()
|
evalPrefix()
|
||||||
|
} else if event.Key() == tcell.KeyEscape {
|
||||||
|
d.open = false
|
||||||
|
d.currentOption = optionBefore
|
||||||
|
setFocus(d)
|
||||||
} else {
|
} else {
|
||||||
d.prefix = ""
|
d.prefix = ""
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue