setSelection sets the selected state of the specified item updating the visual appearance of the list if necessary
(litem *ListItem, state bool, force bool, dispatch bool)
| 418 | // setSelection sets the selected state of the specified item |
| 419 | // updating the visual appearance of the list if necessary |
| 420 | func (li *List) setSelection(litem *ListItem, state bool, force bool, dispatch bool) { |
| 421 | |
| 422 | Manager().SetKeyFocus(li) |
| 423 | // If already at this state, nothing to do |
| 424 | if litem.selected == state && !force { |
| 425 | return |
| 426 | } |
| 427 | litem.SetSelected(state) |
| 428 | |
| 429 | // If single selection, deselects all other items |
| 430 | if li.single { |
| 431 | for _, curr := range li.items { |
| 432 | if curr.(*ListItem) != litem { |
| 433 | curr.(*ListItem).SetSelected(false) |
| 434 | curr.(*ListItem).SetHighlighted(false) |
| 435 | } |
| 436 | } |
| 437 | } |
| 438 | li.update() |
| 439 | if dispatch { |
| 440 | li.Dispatch(OnChange, nil) |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | // update updates the visual state the list and its items |
| 445 | func (li *List) update() { |
no test coverage detected