Record checkForm type ConsoleForm {formSize=[12,40]}
myCheck consoleCheckbox
{name = "simpleCheck",
text = "Click here",
bounds=[4,4,1,15]};
end
checkState boolean = false;
myForm checkForm {};
openUI myForm
bind checkState
//event handlers go here
end
onEvent(ConsoleCheckbox.STATE_CHANGED : "simpleCheck")
if (checkState == true)
SysLib.writeStderr("Checked");
else
SysLib.writeStderr("Cleared");
end
A complete example of a Console UI program that uses a check box in this way follows:
package programs;
import forms.checkForm;
program simpleCheckbox type BasicProgram
function main()
myWindow WINDOW {name="myWindow", position = [1,1]};
openWindow(myWindow);
myForm checkForm {};
displayForm(myForm);
textValue string = "Text.";
keepGoing boolean = true;
myCheckVar boolean = false;
while (keepGoing == true)
openUI myForm
bind textValue, myCheckVar
onEvent(ConsoleButton.PUSHED : "exitButton")
keepGoing = false;
onEvent(ConsoleCheckbox.STATE_CHANGED : "simpleCheck")
if (myCheckVar == true)
textValue = "Checked";
else
textValue = "Cleared";
end
end
end
end
end
package forms;
record checkForm type ConsoleForm { formsize=[12,40] }
introText consoleField
{name="introText",
position = [1,1],
fieldLen = 20};
myCheck consoleCheckbox
{name="simpleCheck",
text="Checkbox",
bounds=[3,5,1,15]};
exitButton consoleButton
{name = "exitButton",
text = "Click to exit",
bounds=[6,4,1,15]};
end