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

Method setSelectedPos

gui/menu.go:373–388  ·  view source on GitHub ↗

setSelectedPos sets the menu item at the specified position as selected and all others as not selected.

(pos int)

Source from the content-addressed store, hash-verified

371// setSelectedPos sets the menu item at the specified position as selected
372// and all others as not selected.
373func (m *Menu) setSelectedPos(pos int) {
374
375 for i := 0; i < len(m.items); i++ {
376 mi := m.items[i]
377 if i == pos {
378 mi.selected = true
379 } else {
380 mi.selected = false
381 }
382 // If menu item has a sub menu, unselects the sub menu options recursively
383 if mi.submenu != nil {
384 mi.submenu.setSelectedPos(-1)
385 }
386 mi.update()
387 }
388}
389
390// setSelectedItem sets the specified menu item as selected
391// and all others as not selected

Callers 3

onKeyMethod · 0.95
onMouseMethod · 0.95
activateMethod · 0.80

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected