summaryrefslogtreecommitdiff
path: root/dropdown.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-07 14:01:49 -0600
committerJeff Carr <[email protected]>2024-02-07 14:01:49 -0600
commit9dd8a8afc9d5cc6c848f3b775d54827bb39b9527 (patch)
treecfa293b53dfdbdd8a5b1eb5df55cfc171321e86b /dropdown.go
parent71bbdd8487293080175eb963a233dbfa68cedc9b (diff)
fix range panic in dropdown menu
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'dropdown.go')
-rw-r--r--dropdown.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/dropdown.go b/dropdown.go
index 80041a7..9f5e4aa 100644
--- a/dropdown.go
+++ b/dropdown.go
@@ -123,13 +123,13 @@ func (w *guiWidget) dropdownClicked(mouseW, mouseH int) string {
log.Log(NOW, "dropdownClicked() at (w,h) =", mouseW, mouseH)
itemNumber := mouseH - startH
- log.Log(NOW, "dropdownClicked() look for item", itemNumber)
+ items := strings.Split(w.labelN, "\n")
+ log.Log(NOW, "dropdownClicked() look for item", itemNumber, "len(items) =", len(items))
if itemNumber < 1 {
return ""
}
- items := strings.Split(w.labelN, "\n")
- if len(items) >= itemNumber-1 {
+ if len(items) >= itemNumber {
log.Log(NOW, "dropdownClicked() found", items[itemNumber-1])
if items[itemNumber-1] != "" {
if me.dropdownW != nil {