Focus SetFocus sets the keyboard input focus on this item or the first item within it that can be focused (if none, then just sets focus to this object). This does not send an [events.Focus] event, which typically results in the widget being styled as focused. See [WidgetBase.SetFocusEvent] for a
()
| 476 | // the widget being styled as focused. See [WidgetBase.SetFocusEvent] for |
| 477 | // a version that does. |
| 478 | func (wb *WidgetBase) SetFocus() { |
| 479 | foc := wb.This.(Widget) |
| 480 | if !wb.AbilityIs(abilities.Focusable) { |
| 481 | foc = wb.focusableInThis() |
| 482 | if foc == nil { |
| 483 | foc = wb.This.(Widget) |
| 484 | } |
| 485 | } |
| 486 | em := wb.Events() |
| 487 | if em != nil { |
| 488 | // fmt.Println("grab focus:", foc) |
| 489 | em.setFocus(foc) // doesn't send event |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | // SetFocusEvent sets the keyboard input focus on this item or the first item within it |
| 494 | // that can be focused (if none, then just sets focus to this object). |
no test coverage detected