MCPcopy
hub / github.com/g3n/engine / newCheckRadio

Function newCheckRadio

gui/checkradio.go:61–99  ·  view source on GitHub ↗

newCheckRadio creates and returns a pointer to a new CheckRadio widget with the specified type and text

(check bool, text string)

Source from the content-addressed store, hash-verified

59// newCheckRadio creates and returns a pointer to a new CheckRadio widget
60// with the specified type and text
61func newCheckRadio(check bool, text string) *CheckRadio {
62
63 cb := new(CheckRadio)
64 cb.styles = &StyleDefault().CheckRadio
65
66 // Adapts to specified type: CheckBox or RadioButton
67 cb.check = check
68 cb.state = false
69 if cb.check {
70 cb.codeON = checkON
71 cb.codeOFF = checkOFF
72 } else {
73 cb.codeON = radioON
74 cb.codeOFF = radioOFF
75 }
76
77 // Initialize panel
78 cb.Panel.Initialize(cb, 0, 0)
79
80 // Subscribe to events
81 cb.Panel.Subscribe(OnKeyDown, cb.onKey)
82 cb.Panel.Subscribe(OnCursorEnter, cb.onCursor)
83 cb.Panel.Subscribe(OnCursorLeave, cb.onCursor)
84 cb.Panel.Subscribe(OnMouseDown, cb.onMouse)
85 cb.Panel.Subscribe(OnEnable, func(evname string, ev interface{}) { cb.update() })
86
87 // Creates label
88 cb.Label = NewLabel(text)
89 cb.Label.Subscribe(OnResize, func(evname string, ev interface{}) { cb.recalc() })
90 cb.Panel.Add(cb.Label)
91
92 // Creates icon label
93 cb.icon = NewIcon(" ")
94 cb.Panel.Add(cb.icon)
95
96 cb.recalc()
97 cb.update()
98 return cb
99}
100
101// Value returns the current state of the checkbox
102func (cb *CheckRadio) Value() bool {

Callers 2

NewCheckBoxFunction · 0.85
NewRadioButtonFunction · 0.85

Calls 8

StyleDefaultFunction · 0.85
NewLabelFunction · 0.85
NewIconFunction · 0.85
SubscribeMethod · 0.65
InitializeMethod · 0.45
updateMethod · 0.45
recalcMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected