If first option is disabled, start at next

Also, accept 'space' as confirmation
This commit is contained in:
Brian Buller 2016-01-09 12:12:23 -06:00
parent 9f978a3ec0
commit 8b0af6e079
1 changed files with 7 additions and 2 deletions

View File

@ -15,7 +15,7 @@ type Menu struct {
disabledBg, disabledFg termbox.Attribute
isDone bool
bordered bool
vimMode bool
vimMode bool
}
// CreateMenu Creates a menu with the specified attributes
@ -252,7 +252,7 @@ func (i *Menu) DisableVimMode() *Menu {
// HandleKeyPress handles the termbox event and returns whether it was consumed
func (i *Menu) HandleKeyPress(event termbox.Event) bool {
if event.Key == termbox.KeyEnter {
if event.Key == termbox.KeyEnter || event.Key == termbox.KeySpace {
i.isDone = true
return true
}
@ -310,6 +310,11 @@ func (i *Menu) Draw() {
}
}
// If the currently selected option is disabled, move to the next
if i.GetSelectedOption().IsDisabled() {
i.SelectNextOption()
}
// Print the options
if len(i.options) > 0 {
for idx := range i.options {