DCheckBoxLabel.GetChecked

From GMod Wiki

Jump to: navigation, search
Function
Syntax DCheckBoxLabel.GetChecked( )
Description:
Used in an if statement to see if a DCheckBoxLabel is checked.
Returns: Boolean Checked
In Object: DCheckBoxLabel
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DCheckBoxLabel.GetChecked]DCheckBoxLabel.GetChecked [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThe caption of a button changes depending on the status of a checkbox.
Used onNewerClient.png
Code
function visibleExample()
 
     local myParent = vgui.Create("Frame");
     myParent:SetPos(100,100);
     myParent:SetSize(100,100);
     myParent:SetVisible(true);
 
     local myCheckBox = vgui.Create( "DCheckBoxLabel", myParent )
     myCheckBox:SetPos(30,60)
     myCheckBox:SetText("I'm a Checkbox")
     myCheckBox:SetValue(0)
     myCheckBox:SizeToContents()
 
     local myButton = vgui.Create("Button", myParent);
     myButton:SetPos(30,30);
     myButton:SetWide(100);
     myButton:SetText("Is my CheckBox checked?");
     function myButton:DoClick()
 
          if myCheckBox:GetChecked() then
               myButton:SetText("YES!!!");
          else
               myButton:SetText("no :(");
          end
 
     end
 
end
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox