Garry's Mod Wiki



Colorful buttons. Used internally by DColorPalette.


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


table DColorButton:GetColor()
Returns the color of the button
number DColorButton:GetID()
Returns the unique ID set by DColorButton:SetID. Used internally by DColorPalette
boolean DColorButton:IsDown()
Returns whether the DColorButton is currently being pressed (the user is holding it down).
DColorButton:SetColor( table color, boolean noTooltip = false )
Sets the color of the DColorButton.
DColorButton:SetID( number id )
Used internally by DColorPalette to detect which button is which.


Creates a DColorButton buton.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 500 ) frame:Center() frame:MakePopup() local DColorButton = vgui.Create( "DColorButton", frame ) DColorButton:SetPos( 1, 28 ) DColorButton:SetSize( 100, 30 ) DColorButton:Paint( 100, 30 ) DColorButton:SetText( "DColorButton" ) DColorButton:SetColor( Color( 0, 110, 160 ) ) function DColorButton:DoClick() -- Callback inherited from DLabel, which is DColorButton's base print( "I am clicked! My color is ", self:GetColor() ) end