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)
| 501 | // corresponding row, setting SelectedIndex and selecting row if found; returns |
| 502 | // true if found, false otherwise. |
| 503 | func (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. |
no test coverage detected