Simplify cursor and dropdown code

This commit is contained in:
2025-06-05 17:17:23 +03:00
parent a2876c2086
commit e14f2d9a74
3 changed files with 42 additions and 38 deletions
+4 -9
View File
@@ -5,7 +5,6 @@ import (
)
type Dropdown struct {
Active bool
Selected int
Options []string
PosX, PosY int
@@ -14,6 +13,7 @@ type Dropdown struct {
}
var dropdowns = make([]*Dropdown, 0)
var ActiveDropdown *Dropdown
func CreateDropdownMenu(options []string, posX, posY, dropdownWidth int, action func(int)) *Dropdown {
if len(options) == 0 {
@@ -31,7 +31,6 @@ func CreateDropdownMenu(options []string, posX, posY, dropdownWidth int, action
}
d := &Dropdown{
Active: false,
Selected: 0,
Options: options,
PosX: posX,
@@ -45,13 +44,9 @@ func CreateDropdownMenu(options []string, posX, posY, dropdownWidth int, action
return d
}
func GetActiveDropdown() *Dropdown {
for _, dropdown := range dropdowns {
if dropdown.Active {
return dropdown
}
}
return nil
func ClearDropdowns() {
dropdowns = make([]*Dropdown, 0)
ActiveDropdown = nil
}
func drawDropdowns(window *Window) {