Difference between revisions of "Lua:Class:CheckBox"

From Cheat Engine
Jump to navigation Jump to search
(Undo revision 1404 by Freiza (Talk))
m (Reverted edits by This content is not available (Talk) to last revision by TheyCallMeTim13)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
and @Rich: This is not about states (the cunerrt state), but the action that performs a change. On most elements, this is the very general action of  click , and for Firefox/Gecko in general, a checked checkbox exposes an action name of  uncheck , and an unchecked checkbox exposes an action name of  check . But since we do not know what the next state of a cunerrtly undetermined checkbox will be, the action name must be something meaningful, but general enough so that the next state can be either checked fully, or unchecked. From other comments in the bug and what I got via e-mail, it looks like we'll call this one  Cycle .
+
[[Category:Lua]]
 +
CheckBox '''Class''': ('''Inheritance''': ''[[Lua:Class:ButtonControl|ButtonControl]]''->''[[Lua:Class:WinControl|WinControl]]''->''[[Lua:Class:Control|Control]]''->''[[Lua:Class:Component|Component]]''->''[[Lua:Class:Object|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
 +
 
 +
== Properties ==
 +
;AllowGrayed
 +
:AllowGrayed Determines if there is a 3th state
 +
 
 +
;State
 +
:The state of the checkbox. 0=Unchecked, 1=Checked, 2=Gray
 +
 
 +
;OnChange(function(sender))
 +
:Function to be called when the state changes
 +
 
 +
 
 +
<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
 +
    checkBoxes[x].Caption="This is checkbox " .. tostring( x )
 +
    checkBoxes[x].setPosition(10, x * 20)
 +
end
 +
 
 +
checkBoxes[1].State=0  -- Sets checkboxes[1] to unchecked state.
 +
checkBoxes[2].State=1  -- Sets checkboxes[2] to checked state.
 +
checkBoxes[3].State=2  -- Sets checkboxes[3] to the gray state
 +
 
 +
if checkBoxes[4].Checked then  -- if checkboxes[4] is checked then the function returns true otherwise false.
 +
  print "true"
 +
else
 +
  print "false"
 +
end
 +
</pre>
 +
 
 +
{{LuaSeeAlso}}

Latest revision as of 19:10, 18 March 2019

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

Properties[edit]

AllowGrayed
AllowGrayed Determines if there is a 3th state
State
The state of the checkbox. 0=Unchecked, 1=Checked, 2=Gray
OnChange(function(sender))
Function to be called when the state changes


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
    checkBoxes[x].Caption="This is checkbox " .. tostring( x )
    checkBoxes[x].setPosition(10, x * 20)
end 

checkBoxes[1].State=0  -- Sets checkboxes[1] to unchecked state.
checkBoxes[2].State=1  -- Sets checkboxes[2] to checked state.
checkBoxes[3].State=2  -- Sets checkboxes[3] to the gray state

if checkBoxes[4].Checked then  -- if checkboxes[4] is checked then the function returns true otherwise false.
   print "true"
else
   print "false"
end

See also[edit]