Wheel IDE

Online demo »

Checkbox

Checkbox example

This example shows how to use the checkbox component.

The windowHandle parameter refers to the active window. When the checkbox value changes then the onCheckboxFormCheckboxChange procedure is called.

Since the status light is on the same window as the checkbox, the windowHandle parameter can be used to address the status light.

Code

#project "Checkbox example"

#include "lib/modules/standard.whl"
#include "lib/modules/components/component.whl"
#include "lib/modules/components/form.whl"
#include "lib/modules/components/checkbox.whl"
#include "lib/modules/components/statusLight.whl"

#define CHECKBOX_FORM_CHECKBOX     0xFD9D281F
#define CHECKBOX_FORM_STATUS_LIGHT 0x112F9C00

#resource "checkbox.wfrm"

number colors[2] = [COMPONENT_COLOR_GRAY, COMPONENT_COLOR_YELLOW]

; @proc                   Checkbox onChange event.
; @param windowHandle     The handle to the active window.
; @param value            The checkbox value.
proc onCheckboxFormCheckboxChange(number windowHandle, number value)
    components.statusLight.setColor(windowHandle, CHECKBOX_FORM_STATUS_LIGHT, colors[value])
end

; @proc                   Show the form.
; @ret                    The handle to the form.
proc showCheckboxFormForm()
    ret components.form.show("checkbox.wfrm")
end

proc main()
    showCheckboxFormForm()
    halt()
end

Screenshot