bug fixes and clean code

This commit is contained in:
2024-09-29 21:22:25 +02:00
parent e873c01e50
commit dd8f1fbc1f
14 changed files with 89 additions and 90 deletions
+8 -7
View File
@@ -8,6 +8,11 @@ import (
"github.com/orus-dev/osui/isKey"
)
type MenuParams struct {
Style MenuStyle
OnSelected func(*MenuComponent, bool)
}
type MenuStyle struct {
Fg string `default:"" type:"fg"`
Bg string `default:"" type:"bg"`
@@ -74,13 +79,9 @@ func (m *MenuComponent) Update(key string) bool {
return false
}
func (m *MenuComponent) SetStyle(c interface{}) {
m.Style = osui.SetDefaults(c.(*MenuStyle)).(*MenuStyle)
}
func (m *MenuComponent) OnSelected(f func(*MenuComponent, bool)) *MenuComponent {
m.onSelected = f
return m
func (b *MenuComponent) Params(param MenuParams) *MenuComponent {
b.Style = osui.SetDefaults(&param.Style).(*MenuStyle)
return b
}
func Menu(items ...string) *MenuComponent {