mirror of
https://github.com/br0xen/termbox-util.git
synced 2024-11-25 14:53:14 +00:00
If first option is disabled, start at next
Also, accept 'space' as confirmation
This commit is contained in:
parent
9f978a3ec0
commit
8b0af6e079
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user