Category:DCheckBoxLabel

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(better example)
 
Line 3: Line 3:
 
|Preview=DCheckBoxLabel_small.png
 
|Preview=DCheckBoxLabel_small.png
 
|Description=The '''DCheckBoxLabel''' is a {{Type|DCheckBox}} with a {{Type|DLabel}} next to it. It allows you to get a boolean value from the user (true/false - yes/no)
 
|Description=The '''DCheckBoxLabel''' is a {{Type|DCheckBox}} with a {{Type|DLabel}} next to it. It allows you to get a boolean value from the user (true/false - yes/no)
 +
|Hooks=
 
}}
 
}}
 
{{Example
 
{{Example
 
|Description=Creates a DCheckBoxLabel, ties it to a convar, and sets its initial value.
 
|Description=Creates a DCheckBoxLabel, ties it to a convar, and sets its initial value.
|Code=local DermaCheckbox = vgui.Create("DCheckBoxLabel") // Create the checkbox
+
|Code=local window = vgui.Create( "DFrame" )
DermaCheckbox:SetParent(DermaPanel)
+
window:SetSize( 300, 200 )
DermaCheckbox:SetPos(25, 50)                       // Set the position
+
window:Center()
DermaCheckbox:SetText("God Mode")                   // Set the text next to the box
+
window:MakePopup()
DermaCheckbox:SetConVar("sbox_godmode")             // Change a ConVar when the box it ticked/unticked
+
 
DermaCheckbox:SetValue(0)             // Initial value (will determine whether the box is ticked too)
+
local DermaCheckbox = window:Add( "DCheckBoxLabel" ) -- Create the checkbox
DermaCheckbox:SizeToContents()                     // Make its size the same as the contents
+
DermaCheckbox:SetPos( 25, 50 ) -- Set the position
|Output=<br/><br/>
+
DermaCheckbox:SetText("God Mode") -- Set the text next to the box
[[Image:DCheckBoxLabel.png]]
+
DermaCheckbox:SetConVar("sbox_godmode") -- Change a ConVar when the box it ticked/unticked
 +
DermaCheckbox:SetValue( true ) -- Initial value
 +
DermaCheckbox:SizeToContents() -- Make its size the same as the contents
 +
|Output=[[Image:DCheckBoxLabel.png]]
 
}}
 
}}

Latest revision as of 18:56, 26 November 2019

Contents

DescriptionPanelPage

The DCheckBoxLabel is a DCheckBox with a DLabel next to it. It allows you to get a boolean value from the user (true/false - yes/no)

Inherited Functions

Inherits the following functions from DPanel and its parents up to 3 levels deep:


Examples

Example

Creates a DCheckBoxLabel, ties it to a convar, and sets its initial value.

local window = vgui.Create( "DFrame" )
window:SetSize( 300, 200 )
window:Center()
window:MakePopup()

local DermaCheckbox = window:Add( "DCheckBoxLabel" ) -- Create the checkbox
DermaCheckbox:SetPos( 25, 50 )						-- Set the position
DermaCheckbox:SetText("God Mode")					-- Set the text next to the box
DermaCheckbox:SetConVar("sbox_godmode")				-- Change a ConVar when the box it ticked/unticked
DermaCheckbox:SetValue( true )						-- Initial value
DermaCheckbox:SizeToContents()						-- Make its size the same as the contents

Output:

DCheckBoxLabel.png
Personal tools
Navigation