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

Method RowGrabFocus

tensor/tensorcore/table.go:556–580  ·  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

554// returns that element or nil if not successful -- note: grid must have
555// already rendered for focus to be grabbed!
556func (tb *Table) RowGrabFocus(row int) *core.WidgetBase {
557 if !tb.IsRowInBounds(row) || tb.InFocusGrab { // range check
558 return nil
559 }
560 nWidgPerRow, idxOff := tb.RowWidgetNs()
561 ridx := nWidgPerRow * row
562 lg := tb.ListGrid
563 // first check if we already have focus
564 for fli := 0; fli < tb.NCols; fli++ {
565 w := lg.Child(ridx + idxOff + fli).(core.Widget).AsWidget()
566 if w.StateIs(states.Focused) || w.ContainsFocus() {
567 return w
568 }
569 }
570 tb.InFocusGrab = true
571 defer func() { tb.InFocusGrab = false }()
572 for fli := 0; fli < tb.NCols; fli++ {
573 w := lg.Child(ridx + idxOff + fli).(core.Widget).AsWidget()
574 if w.CanFocus() {
575 w.SetFocusEvent()
576 return w
577 }
578 }
579 return nil
580}
581
582//////////////////////////////////////////////////////
583// Header layout

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