@@ -390,6 +390,7 @@ func (l *List) SelectedItemInView() bool {
392// SetSelected sets the selected item index in the list.
392// SetSelected sets the selected item index in the list.
393+// It returns -1 if the index is out of bounds.
393func (l *List) SetSelected(index int) {
394func (l *List) SetSelected(index int) {
394 if index < 0 || index >= len(l.items) {
395 if index < 0 || index >= len(l.items) {
395 l.selectedIdx = -1
396 l.selectedIdx = -1
@@ -415,31 +416,43 @@ func (l *List) IsSelectedLast() bool {
417// SelectPrev selects the previous item in the list.
418// SelectPrev selects the previous item in the list.
419+// It returns whether the selection changed.
418−func (l *List) SelectPrev() {
420+func (l *List) SelectPrev() bool {
419 if l.selectedIdx > 0 {
421 if l.selectedIdx > 0 {
420 l.selectedIdx--
422 l.selectedIdx--
424// SelectNext selects the next item in the list.
428// SelectNext selects the next item in the list.
429+// It returns whether the selection changed.
425−func (l *List) SelectNext() {
430+func (l *List) SelectNext() bool {
426 if l.selectedIdx < len(l.items)-1 {
431 if l.selectedIdx < len(l.items)-1 {
427 l.selectedIdx++
432 l.selectedIdx++
431// SelectFirst selects the first item in the list.
438// SelectFirst selects the first item in the list.
439+// It returns whether the selection changed.
432−func (l *List) SelectFirst() {
440+func (l *List) SelectFirst() bool {
433 if len(l.items) > 0 {
441 if len(l.items) > 0 {
434 l.selectedIdx = 0
442 l.selectedIdx = 0
438// SelectLast selects the last item in the list.
448// SelectLast selects the last item in the list.
449+// It returns whether the selection changed.
439−func (l *List) SelectLast() {
450+func (l *List) SelectLast() bool {
440 if len(l.items) > 0 {
451 if len(l.items) > 0 {
441 l.selectedIdx = len(l.items) - 1
452 l.selectedIdx = len(l.items) - 1
445// SelectedItem returns the currently selected item. It may be nil if no item
458// SelectedItem returns the currently selected item. It may be nil if no item