diff options
| author | Pietro Gagliardi <[email protected]> | 2014-02-15 18:36:14 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-02-15 18:36:42 -0500 |
| commit | 992d43ac7b93353448250fade4c0d68ee3160758 (patch) | |
| tree | eca0070637c407d91abc8cd82f1539e38705f20d /listbox.go | |
| parent | 2d97a2446304daa1d57121d13143cce2ceaf69a3 (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.go | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -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() |
