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

Method updateStackTop

core/switch.go:233–251  ·  view source on GitHub ↗

updateStackTop updates the [Frame.StackTop] of the stack in the switch according to the current icon. It is called automatically to keep the switch up-to-date.

()

Source from the content-addressed store, hash-verified

231// according to the current icon. It is called automatically to keep the
232// switch up-to-date.
233func (sw *Switch) updateStackTop() {
234 st, ok := sw.ChildByName("stack", 0).(*Frame)
235 if !ok {
236 return
237 }
238 switch {
239 case sw.StateIs(states.Indeterminate):
240 st.StackTop = 2
241 case sw.IsChecked():
242 st.StackTop = 0
243 default:
244 if sw.Type == SwitchChip {
245 // chips render no icon when off
246 st.StackTop = -1
247 return
248 }
249 st.StackTop = 1
250 }
251}
252
253// SetType sets the styling type of the switch.
254func (sw *Switch) SetType(typ SwitchTypes) *Switch {

Callers 2

InitMethod · 0.95
RenderMethod · 0.95

Calls 3

IsCheckedMethod · 0.95
ChildByNameMethod · 0.80
StateIsMethod · 0.80

Tested by

no test coverage detected