Garry's Mod Wiki

DCheckBox

Description

The DCheckBox is a checkbox. It allows you to get a boolean value from the user (true/false - yes/no)

View source

Parent

Derives methods, etc not listed on this page from DButton.

Implements

Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.

Events

DCheckBox:OnChange( boolean bVal )
Called when the "checked" state is changed. This is for Overriding

Methods

DCheckBox:DoClick()
Calls DCheckBox:Toggle
boolean DCheckBox:GetChecked()
An AccessorFunc that gets the checked state of the checkbox.
boolean DCheckBox:IsEditing()
Returns whether the state of the checkbox is being edited. This means whether the user is currently clicking (mouse-down) on the checkbox, and applies to both the left and right mouse buttons.
DCheckBox:SetChecked( boolean checked )
An AccessorFunc that sets the checked state of the checkbox. Does not call the checkbox's DCheckBox:OnChange and Panel:ConVarChanged methods, unlike DCheckBox:SetValue.
DCheckBox:SetValue( boolean checked )
Sets the checked state of the checkbox, and calls the checkbox's DCheckBox:OnChange and Panel:ConVarChanged methods.
DCheckBox:Toggle()
Toggles the checked state of the checkbox, and calls the checkbox's DCheckBox:OnChange and Panel:ConVarChanged methods. DCheckBox:DoClick is an alias of this function.

Example

Creates a DCheckBox and sets its initial value.

local window = vgui.Create( "DFrame" ) window:SetSize( 300, 200 ) window:Center() window:MakePopup() local checkbox = window:Add( "DCheckBox" ) -- Create the checkbox checkbox:SetPos( 25, 50 ) -- Set the position checkbox:SetValue( true ) -- Initial "ticked" value
Output:
July08-300-gmod.gif