MCPcopy Create free account
hub / github.com/cogentcore/core / selectFieldValue

Method selectFieldValue

core/table.go:503–515  ·  view source on GitHub ↗

selectFieldValue sets SelectedField and SelectedValue and attempts to find corresponding row, setting SelectedIndex and selecting row if found; returns true if found, false otherwise.

(fld, val string)

Source from the content-addressed store, hash-verified

501// corresponding row, setting SelectedIndex and selecting row if found; returns
502// true if found, false otherwise.
503func (tb *Table) selectFieldValue(fld, val string) bool {
504 tb.SelectedField = fld
505 tb.SelectedValue = val
506 if tb.SelectedField != "" && tb.SelectedValue != nil {
507 idx, _ := structSliceIndexByValue(tb.Slice, tb.SelectedField, tb.SelectedValue)
508 if idx >= 0 {
509 tb.ScrollToIndex(idx)
510 tb.updateSelectIndex(idx, true, events.SelectOne)
511 return true
512 }
513 }
514 return false
515}
516
517// structSliceIndexByValue searches for first index that contains given value in field of
518// given name.

Callers 1

setSelectedFileMethod · 0.80

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 3

structSliceIndexByValueFunction · 0.85
ScrollToIndexMethod · 0.80
updateSelectIndexMethod · 0.80

Tested by

no test coverage detected