diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-03-19 10:57:31 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-03-19 10:57:31 +0200 |
commit | 43127dad0f0c190b0ac93e8f54ff4f16eec9c28c (patch) | |
tree | 3618295abad84632324022a7b2bfe673adf39543 /ui/widget | |
parent | 7a4b108b37ccf415f75d74738dddbdba23af1805 (diff) |
Switch forms to use advanced inputfields and use user-friendly panics for UI errors
Diffstat (limited to 'ui/widget')
-rw-r--r-- | ui/widget/advanced-inputfield.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/widget/advanced-inputfield.go b/ui/widget/advanced-inputfield.go index 6928c27..6cb1d00 100644 --- a/ui/widget/advanced-inputfield.go +++ b/ui/widget/advanced-inputfield.go @@ -75,7 +75,7 @@ type AdvancedInputField struct { changed func(text string) // An optional function which is called when the user indicated that they - // are done entering text. The key which was pressed is provided (enter or escape). + // are done entering text. The key which was pressed is provided (enter, tab, backtab or escape). done func(tcell.Key) // An optional function which is called when the user presses tab. @@ -200,6 +200,8 @@ func (field *AdvancedInputField) SetChangedFunc(handler func(text string)) *Adva // // - KeyEnter: Done entering text. // - KeyEscape: Abort text input. +// - KeyTab: Tab +// - KeyBacktab: Shift + Tab func (field *AdvancedInputField) SetDoneFunc(handler func(key tcell.Key)) *AdvancedInputField { field.done = handler return field @@ -435,8 +437,10 @@ func (field *AdvancedInputField) InputHandler() func(event *tcell.EventKey, setF if oldWidth != newWidth { field.cursorOffset += newWidth - oldWidth } + break } - case tcell.KeyEnter, tcell.KeyEscape: // We're done. + fallthrough + case tcell.KeyEnter, tcell.KeyEscape, tcell.KeyBacktab: // We're done. if field.done != nil { field.done(key) } |