MCPcopy Create free account
hub / github.com/SolarLune/masterplan / NewCheckbox

Function NewCheckbox

gui.go:422–455  ·  view source on GitHub ↗
(x, y float32, worldSpace bool, property *Property)

Source from the content-addressed store, hash-verified

420}
421
422func NewCheckbox(x, y float32, worldSpace bool, property *Property) *Checkbox {
423 checkbox := &Checkbox{
424 IconButton: *NewIconButton(x, y, &sdl.FRect{48, 0, 32, 32}, globals.GUITexture, worldSpace, nil),
425 InactiveSrcPos: Vector{48, 0},
426 ActiveSrcPos: Vector{48, 32},
427 }
428
429 r := *checkbox.IconButton.Rect
430 checkbox.Rect = &r
431
432 checkbox.Property = property
433
434 checkbox.OnPressed = func() {
435
436 if !checkbox.CanPress {
437 return
438 }
439
440 PlayUISound(UISoundTypeSelect)
441
442 if checkbox.Property != nil {
443 checkbox.Property.Set(!checkbox.Property.AsBool())
444 } else {
445 checkbox.Checked = !checkbox.Checked
446 }
447
448 if checkbox.OnChange != nil {
449 checkbox.OnChange()
450 }
451
452 }
453
454 return checkbox
455}
456
457func (checkbox *Checkbox) Update() {
458

Callers 3

NewCheckboxContentsFunction · 0.85
NewNumberedContentsFunction · 0.85
ConstructMenusFunction · 0.85

Calls 4

NewIconButtonFunction · 0.85
PlayUISoundFunction · 0.85
AsBoolMethod · 0.80
SetMethod · 0.45

Tested by

no test coverage detected