summaryrefslogtreecommitdiff
path: root/listbox.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-02-15 18:36:14 -0500
committerPietro Gagliardi <[email protected]>2014-02-15 18:36:42 -0500
commit992d43ac7b93353448250fade4c0d68ee3160758 (patch)
treeeca0070637c407d91abc8cd82f1539e38705f20d /listbox.go
parent2d97a2446304daa1d57121d13143cce2ceaf69a3 (diff)
Added Listbox.Selection() and Listbox.SelectedIndices(). Also fixed a bug involving sysData.selectedIndices() with nothing selected.
Diffstat (limited to 'listbox.go')
-rw-r--r--listbox.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/listbox.go b/listbox.go
index 3c422c2..cba3925 100644
--- a/listbox.go
+++ b/listbox.go
@@ -65,9 +65,27 @@ func (l *Listbox) Delete(index int) error {
return nil
}
-// TODO Selection
+// Selection returns a list of strings currently selected in the Listbox, or an empty list if none have been selected. This list will have at most one item on a single-selection Listbox.
+func (l *Listbox) Selection() []string {
+ l.lock.Lock()
+ defer l.lock.Unlock()
+
+ if l.created {
+ return l.sysData.selectedTexts()
+ }
+ return nil
+}
-// TODO SelectedIndices
+// SelectedIndices returns a list of the currently selected indexes in the Listbox, or an empty list if none have been selected. This list will have at most one item on a single-selection Listbox.
+func (l *Listbox) SelectedIndices() []int {
+ l.lock.Lock()
+ defer l.lock.Unlock()
+
+ if l.created {
+ return l.sysData.selectedIndices()
+ }
+ return nil
+}
func (l *Listbox) make(window *sysData) (err error) {
l.lock.Lock()