KeyMap Expansion

This commit is contained in:
2025-07-31 13:31:14 -05:00
parent 174fab2c6d
commit 9e88799391
7 changed files with 111 additions and 54 deletions

13
menu.go
View File

@@ -41,6 +41,7 @@ type Menu struct {
onPressed func() bool
manualExpand bool
expanded bool
vimMode bool
keyMap KeyMap
}
@@ -62,12 +63,12 @@ func (w *Menu) Init(id string, style tcell.Style) {
w.id = id
w.style = style
w.visible = true
w.keyMap = NewKeyMap(map[tcell.Key]func() bool{
w.keyMap = NewKeyMap(map[tcell.Key]func(ev *tcell.EventKey) bool{
tcell.KeyRight: w.MoveRight,
tcell.KeyLeft: w.MoveLeft,
tcell.KeyUp: w.MoveUp,
tcell.KeyDown: w.MoveDown,
tcell.KeyEnter: func() bool {
tcell.KeyEnter: func(ev *tcell.EventKey) bool {
if w.onPressed != nil {
return w.onPressed()
}
@@ -201,7 +202,7 @@ func (w *Menu) AddItems(iL ...Widget) {
w.SetW(maxW)
}
func (w *Menu) MoveRight() bool {
func (w *Menu) MoveRight(ev *tcell.EventKey) bool {
if w.menuType != MenuTypeH {
return false
}
@@ -209,7 +210,7 @@ func (w *Menu) MoveRight() bool {
return true
}
func (w *Menu) MoveLeft() bool {
func (w *Menu) MoveLeft(ev *tcell.EventKey) bool {
if w.menuType != MenuTypeH {
return false
}
@@ -217,7 +218,7 @@ func (w *Menu) MoveLeft() bool {
return true
}
func (w *Menu) MoveUp() bool {
func (w *Menu) MoveUp(ev *tcell.EventKey) bool {
if w.menuType != MenuTypeV {
return false
}
@@ -225,7 +226,7 @@ func (w *Menu) MoveUp() bool {
return true
}
func (w *Menu) MoveDown() bool {
func (w *Menu) MoveDown(ev *tcell.EventKey) bool {
if w.menuType != MenuTypeV {
return false
}