2 Commits

Author SHA1 Message Date
4b51c5b00f Show/Hide Menu Functions 2026-02-18 15:56:20 -06:00
46a87f913b Bug Fixes 2026-02-02 13:38:33 -06:00
3 changed files with 42 additions and 28 deletions

View File

@@ -285,8 +285,7 @@ func (w *LinearLayout) ActivateWidget(n Widget) {
func (w *LinearLayout) ActivateNext() bool { func (w *LinearLayout) ActivateNext() bool {
var found bool var found bool
for i := range w.widgets { for i := range w.widgets {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true
@@ -299,8 +298,7 @@ func (w *LinearLayout) ActivateNext() bool {
func (w *LinearLayout) ActivatePrev() bool { func (w *LinearLayout) ActivatePrev() bool {
var found bool var found bool
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true

View File

@@ -79,8 +79,7 @@ func (w *ScrollingWidgetList) Init(id string, s tcell.Style) {
if active == nil && len(w.widgets) > 0 { if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some // No widget is active, but we do have some
for i := range w.widgets { for i := range w.widgets {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -93,8 +92,7 @@ func (w *ScrollingWidgetList) Init(id string, s tcell.Style) {
if active == nil && len(w.widgets) > 0 { if active == nil && len(w.widgets) > 0 {
// No widget is active, but we do have some // No widget is active, but we do have some
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if w.widgets[i].Focusable() { if w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} }
} }
@@ -167,8 +165,6 @@ func (w *ScrollingWidgetList) SetActive(a bool) bool {
} }
func (w *ScrollingWidgetList) Visible() bool { return w.visible } func (w *ScrollingWidgetList) Visible() bool { return w.visible }
func (w *ScrollingWidgetList) SetVisible(a bool) { w.visible = a } func (w *ScrollingWidgetList) SetVisible(a bool) { w.visible = a }
func (w *ScrollingWidgetList) Focusable() bool { return w.focusable }
func (w *ScrollingWidgetList) SetFocusable(b bool) { w.focusable = b }
func (w *ScrollingWidgetList) SetX(x int) { w.x = x } func (w *ScrollingWidgetList) SetX(x int) { w.x = x }
func (w *ScrollingWidgetList) SetY(y int) { w.y = y } func (w *ScrollingWidgetList) SetY(y int) { w.y = y }
func (w *ScrollingWidgetList) GetX() int { return w.x } func (w *ScrollingWidgetList) GetX() int { return w.x }
@@ -284,8 +280,7 @@ func (w *ScrollingWidgetList) ActivateWidget(n Widget) {
func (w *ScrollingWidgetList) ActivateNext() bool { func (w *ScrollingWidgetList) ActivateNext() bool {
var found bool var found bool
for i := range w.widgets { for i := range w.widgets {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true
@@ -298,8 +293,7 @@ func (w *ScrollingWidgetList) ActivateNext() bool {
func (w *ScrollingWidgetList) ActivatePrev() bool { func (w *ScrollingWidgetList) ActivatePrev() bool {
var found bool var found bool
for i := len(w.widgets) - 1; i >= 0; i-- { for i := len(w.widgets) - 1; i >= 0; i-- {
if found && w.widgets[i].Focusable() { if found && w.widgets[i].SetActive(true) {
w.widgets[i].SetActive(true)
return true return true
} else if w.widgets[i].Active() { } else if w.widgets[i].Active() {
found = true found = true

View File

@@ -78,6 +78,28 @@ func (w *TopMenuLayout) Init(id string, s tcell.Style) {
) )
} }
func (w *TopMenuLayout) HideMenu() bool {
if w.menu == nil {
return false
}
w.menu.SetActive(false)
if w.widget != nil {
w.widget.SetActive(true)
}
return true
}
func (w *TopMenuLayout) ShowMenu() bool {
if w.menu == nil {
return false
}
w.menu.SetActive(true)
if w.widget != nil {
w.widget.SetActive(false)
}
return true
}
func (w *TopMenuLayout) ToggleMenu() bool { func (w *TopMenuLayout) ToggleMenu() bool {
if w.menu != nil { if w.menu != nil {
w.menu.SetActive(!w.menu.Active()) w.menu.SetActive(!w.menu.Active())