mirror of
https://github.com/br0xen/termbox-util.git
synced 2025-08-18 11:44:06 -05:00
If first option is disabled, start at next
Also, accept 'space' as confirmation
This commit is contained in:
@@ -15,7 +15,7 @@ type Menu struct {
|
|||||||
disabledBg, disabledFg termbox.Attribute
|
disabledBg, disabledFg termbox.Attribute
|
||||||
isDone bool
|
isDone bool
|
||||||
bordered bool
|
bordered bool
|
||||||
vimMode bool
|
vimMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMenu Creates a menu with the specified attributes
|
// 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
|
// HandleKeyPress handles the termbox event and returns whether it was consumed
|
||||||
func (i *Menu) HandleKeyPress(event termbox.Event) bool {
|
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
|
i.isDone = true
|
||||||
return 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
|
// Print the options
|
||||||
if len(i.options) > 0 {
|
if len(i.options) > 0 {
|
||||||
for idx := range i.options {
|
for idx := range i.options {
|
||||||
|
Reference in New Issue
Block a user