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)
| 554 | // returns that element or nil if not successful -- note: grid must have |
| 555 | // already rendered for focus to be grabbed! |
| 556 | func (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 |
nothing calls this directly
no test coverage detected