setSelectedPos sets the menu item at the specified position as selected and all others as not selected.
(pos int)
| 371 | // setSelectedPos sets the menu item at the specified position as selected |
| 372 | // and all others as not selected. |
| 373 | func (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 |