mirror of https://github.com/rivo/tview.git
Added GetFocusedItemIndex() to Form. Resolves #293
This commit is contained in:
parent
6e00e540f2
commit
c5f3e4f883
13
form.go
13
form.go
|
@ -341,6 +341,19 @@ func (f *Form) GetFormItemIndex(label string) int {
|
||||||
return -1
|
return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFocusedItemIndex returns the indices of the form element or button which
|
||||||
|
// currently has focus. If they don't, -1 is returned resepectively.
|
||||||
|
func (f *Form) GetFocusedItemIndex() (formItem, button int) {
|
||||||
|
index := f.focusIndex()
|
||||||
|
if index < 0 {
|
||||||
|
return -1, -1
|
||||||
|
}
|
||||||
|
if index < len(f.items) {
|
||||||
|
return index, -1
|
||||||
|
}
|
||||||
|
return -1, index - len(f.items)
|
||||||
|
}
|
||||||
|
|
||||||
// SetCancelFunc sets a handler which is called when the user hits the Escape
|
// SetCancelFunc sets a handler which is called when the user hits the Escape
|
||||||
// key.
|
// key.
|
||||||
func (f *Form) SetCancelFunc(callback func()) *Form {
|
func (f *Form) SetCancelFunc(callback func()) *Form {
|
||||||
|
|
Loading…
Reference in New Issue