Garry's Mod Wiki

DColorButton

Description

Colorful buttons. Used internally by DColorPalette.

View source

Parent

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

Implements

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

Methods

table DColorButton:GetColor()
An AccessorFunc that returns the color of the button
boolean DColorButton:GetDrawBorder()
We advise against using this. It may be changed or removed in a future update. An AccessorFunc that returns value set by DColorButton:SetDrawBorder. See that page for more info.
number DColorButton:GetID()
An AccessorFunc that returns the unique ID set by DColorButton:SetID. Used internally by DColorPalette
boolean DColorButton:GetSelected()
We advise against using this. It may be changed or removed in a future update. An AccessorFunc that is an alias of Panel:IsSelected.
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:SetDrawBorder( boolean draw )
We advise against using this. It may be changed or removed in a future update. An AccessorFunc that does absolutely nothing at all. Default value is automatically set to true.
DColorButton:SetID( number id )
An AccessorFunc that is used internally by DColorPalette to detect which button is which. Pairs with DColorButton:GetID

Example

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

preview from the derma_controls concmd - mouse is hovering over this button to display tooltip

image.png