MCPcopy
hub / github.com/g3n/engine / setSelection

Method setSelection

gui/list.go:420–442  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

418// setSelection sets the selected state of the specified item
419// updating the visual appearance of the list if necessary
420func (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
445func (li *List) update() {

Callers 3

onKeyEventMethod · 0.95
onMouseMethod · 0.80
onCursorMethod · 0.80

Calls 6

updateMethod · 0.95
ManagerFunction · 0.85
SetKeyFocusMethod · 0.80
SetHighlightedMethod · 0.80
DispatchMethod · 0.65
SetSelectedMethod · 0.45

Tested by

no test coverage detected