Difference between revisions of "Lua:Class:CheckBox"
m (Reverted edits by 187.1.1.230 (Talk) to last revision by Dark Byte) |
|||
| Line 1: | Line 1: | ||
| − | + | '''CheckBox Class''' (Inheritance ButtonControl->WinControl->Control->Component->Object) | |
| + | The Checkbox is a visual component that lets the user click it and change state between checked, unchecked, and if possible, grayed | ||
| + | |||
| + | |||
| + | '''createCheckBox(owner)''' | ||
| + | Creates a CheckBox class object which belongs to the given owner. Owner can be any object inherited from WinControl | ||
| + | |||
| + | ''' | ||
| + | checkbox_getAllowGrayed(CheckBox)''' | ||
| + | Gets the AllowGrayed property | ||
| + | |||
| + | |||
| + | '''checkbox_setAllowGrayed(CheckBox, boolean)''' -- it is same as '''control_setEnabled(control, ~ boolean)''' | ||
| + | Sets the AllowGrayed property | ||
| + | |||
| + | |||
| + | '''checkbox_getState(checkbox)''' | ||
| + | Gets the current state of the checkbox | ||
| + | 0=Unchecked | ||
| + | 1=Checked | ||
| + | 2=Grayed | ||
| + | |||
| + | ''' | ||
| + | checkbox_setState(checkbox, state)''' | ||
| + | Sets the state of the checkbox | ||
| + | 0=Unchecked | ||
| + | 1=Checked | ||
| + | 2=Grayed | ||
| + | |||
| + | |||
| + | checkbox_onChange(checkbox, function) | ||
| + | Sets an OnChange event for the checkbox that gets triggered when the state has been changed (by the user of programatically) | ||
| + | function (sender) | ||
| + | |||
| + | |||
| + | <pre> | ||
| + | Example: | ||
| + | |||
| + | local form = createForm( true ); | ||
| + | |||
| + | local checkBoxes = {}; | ||
| + | checkBoxes[1] = createCheckBox( form ); | ||
| + | checkBoxes[2] = createCheckBox( form ); | ||
| + | checkBoxes[3] = createCheckBox( form ); | ||
| + | checkBoxes[4] = createCheckBox( form ); | ||
| + | checkBoxes[5] = createCheckBox( form ); | ||
| + | |||
| + | for x = 1, #checkBoxes do | ||
| + | control_setCaption( checkBoxes[x], "This is checkbox " .. tostring( x ) ); | ||
| + | control_setPosition( checkBoxes[x], 10, x * 20 ) | ||
| + | end | ||
| + | |||
| + | checkbox_setState(checkboxes[1], 0) -- Sets checkboxes[1] to unchecked state. | ||
| + | checkbox_setState(checkboxes[2], 1) -- Sets checkboxes[2] to checked state. | ||
| + | checkbox_setState(checkboxes[3], 2) -- checkboxes[3] is grayed out. | ||
| + | |||
| + | if checkbox_getState(checkboxes[4]) then -- if checkboxes[4] is checked then the function returns true otherwise false. | ||
| + | print "true" | ||
| + | else | ||
| + | print "false" | ||
| + | end | ||
| + | </pre> | ||
Revision as of 14:40, 13 May 2012
CheckBox Class (Inheritance ButtonControl->WinControl->Control->Component->Object) The Checkbox is a visual component that lets the user click it and change state between checked, unchecked, and if possible, grayed
createCheckBox(owner)
Creates a CheckBox class object which belongs to the given owner. Owner can be any object inherited from WinControl
checkbox_getAllowGrayed(CheckBox) Gets the AllowGrayed property
checkbox_setAllowGrayed(CheckBox, boolean) -- it is same as control_setEnabled(control, ~ boolean)
Sets the AllowGrayed property
checkbox_getState(checkbox)
Gets the current state of the checkbox
0=Unchecked 1=Checked 2=Grayed
checkbox_setState(checkbox, state) Sets the state of the checkbox
0=Unchecked 1=Checked 2=Grayed
checkbox_onChange(checkbox, function)
Sets an OnChange event for the checkbox that gets triggered when the state has been changed (by the user of programatically)
function (sender)
Example:
local form = createForm( true );
local checkBoxes = {};
checkBoxes[1] = createCheckBox( form );
checkBoxes[2] = createCheckBox( form );
checkBoxes[3] = createCheckBox( form );
checkBoxes[4] = createCheckBox( form );
checkBoxes[5] = createCheckBox( form );
for x = 1, #checkBoxes do
control_setCaption( checkBoxes[x], "This is checkbox " .. tostring( x ) );
control_setPosition( checkBoxes[x], 10, x * 20 )
end
checkbox_setState(checkboxes[1], 0) -- Sets checkboxes[1] to unchecked state.
checkbox_setState(checkboxes[2], 1) -- Sets checkboxes[2] to checked state.
checkbox_setState(checkboxes[3], 2) -- checkboxes[3] is grayed out.
if checkbox_getState(checkboxes[4]) then -- if checkboxes[4] is checked then the function returns true otherwise false.
print "true"
else
print "false"
end