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

Method SetFocus

core/widgetevents.go:478–491  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

476// the widget being styled as focused. See [WidgetBase.SetFocusEvent] for
477// a version that does.
478func (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).

Callers 9

handleWidgetClickMethod · 0.95
selectUpdateMethod · 0.80
moveDownEventMethod · 0.80
moveUpEventMethod · 0.80
movePageUpEventMethod · 0.80
movePageDownEventMethod · 0.80
moveHomeEventMethod · 0.80
moveEndEventMethod · 0.80
InitMethod · 0.80

Calls 4

AbilityIsMethod · 0.95
focusableInThisMethod · 0.95
EventsMethod · 0.95
setFocusMethod · 0.80

Tested by

no test coverage detected