Explorar o código

Now able to check which item is selected in Dropdown.

Cedar Mora %!s(int64=7) %!d(string=hai) anos
pai
achega
0af1a82a74
Modificáronse 2 ficheiros con 9 adicións e 1 borrados
  1. 8 1
      gui/dropdown.go
  2. 1 0
      gui/list.go

+ 8 - 1
gui/dropdown.go

@@ -113,10 +113,17 @@ func (dd *DropDown) Selected() *ImageLabel {
 	return dd.selItem
 }
 
+// SelectedPos returns the currently selected position or -1 if no item was selected
+func (dd *DropDown) SelectedPos() int {
+	return dd.list.selected()
+}
+
 // SetSelected sets the selected item
 func (dd *DropDown) SetSelected(item *ImageLabel) {
-
+	dd.list.SetSelected(dd.selItem, false)
 	dd.list.SetSelected(item, true)
+	dd.copySelected()
+	dd.update()
 }
 
 // SelectPos selects the item at the specified position

+ 1 - 0
gui/list.go

@@ -440,6 +440,7 @@ func (li *List) setSelection(litem *ListItem, state bool, force bool, dispatch b
 		for _, curr := range li.items {
 			if curr.(*ListItem) != litem {
 				curr.(*ListItem).SetSelected(false)
+				curr.(*ListItem).SetHighlighted(false)
 			}
 		}
 	}