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

Method SetFocusEvent

core/widgetevents.go:498–511  ·  view source on GitHub ↗

SetFocusEvent 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 sends an [events.Focus] event, which typically results in the widget being styled as focused. See [WidgetBase.SetFocus] for a version that doe

()

Source from the content-addressed store, hash-verified

496// the widget being styled as focused. See [WidgetBase.SetFocus] for
497// a version that does not.
498func (wb *WidgetBase) SetFocusEvent() {
499 foc := wb.This.(Widget)
500 if !wb.AbilityIs(abilities.Focusable) {
501 foc = wb.focusableInThis()
502 if foc == nil {
503 foc = wb.This.(Widget)
504 }
505 }
506 em := wb.Events()
507 if em != nil {
508 // fmt.Println("grab focus:", foc)
509 em.setFocusEvent(foc) // doesn't send event
510 }
511}
512
513// focusableInThis returns the first Focusable element within this widget
514func (wb *WidgetBase) focusableInThis() Widget {

Callers 9

RowGrabFocusMethod · 0.80
InitMethod · 0.80
RowGrabFocusMethod · 0.80
InitMethod · 0.80
clearMethod · 0.80
managerKeyChordEventsMethod · 0.80
MakeGridMethod · 0.80
RowGrabFocusMethod · 0.80
handleMouseMethod · 0.80

Calls 4

AbilityIsMethod · 0.95
focusableInThisMethod · 0.95
EventsMethod · 0.95
setFocusEventMethod · 0.80

Tested by

no test coverage detected