DCheckBoxLabel.OnChange

From GMod Wiki

Jump to: navigation, search
Function
Syntax DCheckBoxLabel.OnChange( Function function )
Description:
Specifies a command to execute when it's value is changed
Returns: nil
In Object: DCheckBoxLabel
Realm: NewerClient.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=DCheckBoxLabel.OnChange]DCheckBoxLabel.OnChange [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThis will change a variable to true of false depending on a checkbox.
Used onNewerClient.png
Code
// 
local DermaPanel = vgui.Create( "DFrame" )
DermaPanel:SetPos( 50,50 )
DermaPanel:SetSize( 200, 250 )
DermaPanel:SetTitle( "Testing DCheckBoxLabel" )
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true )
DermaPanel:ShowCloseButton( true )
DermaPanel:MakePopup()
local onOrOff = false
local CheckBoxThing = vgui.Create( "DCheckBoxLabel", DermaPanel )
CheckBoxThing:SetPos( 10,50 )
CheckBoxThing:SetText( "On or Off" )
CheckBoxThing:SetValue( 0 )
CheckBoxThing.OnChange = function(pSelf, fValue)
   onOrOff = fValue
end
 
CheckBoxThing:SizeToContents()
 
OutputTurns variable onOrOff to true if the checkbox is checked, false otherwise
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox