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

Method Init

core/keybutton.go:49–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

47func (kc *KeyChordButton) WidgetValue() any { return &kc.Chord }
48
49func (kc *KeyChordButton) Init() {
50 kc.Button.Init()
51 kc.SetType(ButtonTonal)
52 kc.OnKeyChord(func(e events.Event) {
53 if !kc.StateIs(states.Focused) {
54 return
55 }
56 kc.Chord = e.KeyChord()
57 e.SetHandled()
58 kc.UpdateChange()
59 })
60 kc.Updater(func() {
61 kc.SetText(kc.Chord.Label())
62 })
63 kc.AddContextMenu(func(m *Scene) {
64 NewButton(m).SetText("Clear").SetIcon(icons.ClearAll).OnClick(func(e events.Event) {
65 kc.Chord = ""
66 kc.UpdateChange()
67 })
68 })
69}

Callers

nothing calls this directly

Calls 14

NewButtonFunction · 0.85
OnKeyChordMethod · 0.80
StateIsMethod · 0.80
UpdateChangeMethod · 0.80
UpdaterMethod · 0.80
AddContextMenuMethod · 0.80
InitMethod · 0.65
KeyChordMethod · 0.65
SetHandledMethod · 0.65
LabelMethod · 0.65
SetIconMethod · 0.65
SetTypeMethod · 0.45

Tested by

no test coverage detected