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

Method RowGrabFocus

core/table.go:474–498  ·  view source on GitHub ↗

RowGrabFocus grabs the focus for the first focusable widget in given row; returns that element or nil if not successful. Note: grid must have already rendered for focus to be grabbed!

(row int)

Source from the content-addressed store, hash-verified

472// returns that element or nil if not successful. Note: grid must have
473// already rendered for focus to be grabbed!
474func (tb *Table) RowGrabFocus(row int) *WidgetBase {
475 if !tb.IsRowInBounds(row) || tb.InFocusGrab { // range check
476 return nil
477 }
478 nWidgPerRow, idxOff := tb.RowWidgetNs()
479 ridx := nWidgPerRow * row
480 lg := tb.ListGrid
481 // first check if we already have focus
482 for fli := 0; fli < tb.numVisibleFields; fli++ {
483 w := lg.Child(ridx + idxOff + fli).(Widget).AsWidget()
484 if w.StateIs(states.Focused) || w.ContainsFocus() {
485 return w
486 }
487 }
488 tb.InFocusGrab = true
489 defer func() { tb.InFocusGrab = false }()
490 for fli := 0; fli < tb.numVisibleFields; fli++ {
491 w := lg.Child(ridx + idxOff + fli).(Widget).AsWidget()
492 if w.CanFocus() {
493 w.SetFocusEvent()
494 return w
495 }
496 }
497 return nil
498}
499
500// selectFieldValue sets SelectedField and SelectedValue and attempts to find
501// corresponding row, setting SelectedIndex and selecting row if found; returns

Callers

nothing calls this directly

Implementers 1

_cogentcore_org_core_plot_plots_Tableyaegicore/symbols/cogentcore_org-core-

Calls 8

RowWidgetNsMethod · 0.95
IsRowInBoundsMethod · 0.80
ChildMethod · 0.80
StateIsMethod · 0.80
ContainsFocusMethod · 0.80
CanFocusMethod · 0.80
SetFocusEventMethod · 0.80
AsWidgetMethod · 0.65

Tested by

no test coverage detected