Garry's Mod Wiki

DLabel

Description

A standard Derma text label. A lot of this panels functionality is a base for button elements, such as DButton

Does not support multiline text.

View source

Parent

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

Events

DLabel:DoClick()
Called when the label is left clicked (on key release) by the player. This will be called after DLabel:OnDepressed and DLabel:OnReleased. This can be overridden; by default, it calls DLabel:Toggle. See also DLabel:DoRightClick, DLabel:DoMiddleClick and DLabel:DoDoubleClick.
DLabel:DoDoubleClick()
Called when the label is double clicked by the player with left clicks. DLabel:SetDoubleClickingEnabled must be set to true for this hook to work, which it is by default. This will be called after DLabel:OnDepressed and DLabel:OnReleased and DLabel:DoClick. See also DLabel:DoRightClick and DLabel:DoMiddleClick.
DLabel:DoMiddleClick()
Called when the label is middle mouse (Mouse wheel, also known as mouse 3) clicked (on key release) by the player. This will be called after DLabel:OnDepressed and DLabel:OnReleased. See also DLabel:DoClick, DLabel:DoRightClick and DLabel:DoDoubleClick.
DLabel:DoRightClick()
Called when the label is right clicked (on key release) by the player. This will be called after DLabel:OnDepressed and DLabel:OnReleased. See also DLabel:DoClick, DLabel:DoMiddleClick and DLabel:DoDoubleClick.
DLabel:OnDepressed()
Called when the player presses the label with any mouse button. This works as an alternative to PANEL:OnMousePressed as that hook is used heavily by DLabel and overriding it will break functionality. See also DLabel:DoClick, DLabel:DoMiddleClick, DLabel:DoRightClick, DLabel:OnReleased and DLabel:DoDoubleClick.
DLabel:OnReleased()
Called when the player releases any mouse button on the label. This is always called after DLabel:OnDepressed. This works as an alternative to PANEL:OnMouseReleased as that hook is used heavily by DLabel and overriding it will break functionality. See also DLabel:DoClick, DLabel:DoMiddleClick, DLabel:DoRightClick and DLabel:DoDoubleClick.
DLabel:OnToggled( boolean toggleState )
Called when the toggle state of the label is changed by DLabel:Toggle. In order to use toggle functionality, you must first call DLabel:SetIsToggle with true, as it is disabled by default.

Methods

DLabel:DoClickInternal()
Called just before DLabel:DoClick. In DLabel does nothing and is safe to override. Used by DMenuOption and DCollapsibleCategory's tabs.
Called just before DLabel:DoDoubleClick. In DLabel does nothing and is safe to override.
Returns whether the label stretches vertically or not. Set by DLabel:SetAutoStretchVertical.
Returns whether the DLabel should set its text color to the current skin's bright text color. See DLabel:SetBright.
table DLabel:GetColor()
Returns the actual color of the text. See also DLabel:GetTextColor and DLabel:GetTextStyleColor.
boolean DLabel:GetDark()
Returns whether the DLabel should set its text color to the current skin's dark text color. See DLabel:SetDark.
We advise against using this. It may be changed or removed in a future update. Use Panel:IsEnabled instead. Gets the disabled state of the DLabel. This is set with DLabel:SetDisabled.
Returns whether or not double clicking will call DLabel:DoDoubleClick. See DLabel:SetDoubleClickingEnabled.
We advise against using this. It may be changed or removed in a future update. You should use DLabel:GetPaintBackground instead. Returns whether or not the panel background is being drawn. Alias of DLabel:GetPaintBackground.
string DLabel:GetFont()
Returns the current font of the DLabel. This is set with DLabel:SetFont.
Returns whether the DLabel should set its text color to the current skin's highlighted text color. See DLabel:SetHighlight.
Used internally by DComboBox. Returns whether the frame is part of a derma menu or not. If this is true, CloseDermaMenus will not be called when the frame is clicked, and thus any open menus will remain open.
Returns whether the toggle functionality is enabled for a label. Set with DLabel:SetIsToggle.
Returns whether or not the background should be painted.
Returns the "override" text color, set by DLabel:SetTextColor.
This is used internally - although you're able to use it you probably shouldn't. Returns the "internal" or fallback color of the text. See also DLabel:GetTextColor and DLabel:SetTextStyleColor.
Returns the current toggle state of the label. This can be set with DLabel:SetToggle and toggled with DLabel:Toggle. In order to use toggle functionality, you must first call DLabel:SetIsToggle with true, as it is disabled by default.
DLabel:SetAutoStretchVertical( boolean stretch )
Automatically adjusts the height of the label dependent of the height of the text inside of it.
DLabel:SetBright( boolean bright )
Sets the color of the text to the bright text color defined in the skin. Disables DLabel:SetDark. Gets overridden by DLabel:SetHighlight. You should only consider using this if you are using background elements that are not manually painted and are using the skin colors. Otherwise use DLabel:SetTextColor.
DLabel:SetColor( table color )
Changes color of label. Alias of DLabel:SetTextColor.
DLabel:SetDark( boolean dark )
Sets the color of the text to the dark text color defined in the skin. Disables DLabel:SetBright. Gets overridden by DLabel:SetHighlight. You should only consider using this if you are using background elements that are not manually painted and are using the skin colors. Otherwise use DLabel:SetTextColor.
DLabel:SetDisabled( boolean disable )
We advise against using this. It may be changed or removed in a future update. Use Panel:SetEnabled instead. Sets the disabled state of the DLabel. When disabled, the label does not respond to click, toggle or drag & drop actions.
Sets whether or not double clicking should call DLabel:DoDoubleClick. This is enabled by default.
DLabel:SetDrawBackground( boolean draw )
We advise against using this. It may be changed or removed in a future update. You should use DLabel:SetPaintBackground instead. Sets whether or not to draw the panel background. Alias of DLabel:SetPaintBackground.
DLabel:SetFont( string fontName )
Sets the font of the label.
DLabel:SetHighlight( boolean highlight )
Sets the color of the text to the highlight text color defined in the skin. For the default Derma skin this makes the label red. Overrides colors set by both DLabel:SetBright and DLabel:SetDark while active. You should only consider using this if you are using background elements that are not manually painted and are using the skin colors. Otherwise use DLabel:SetTextColor.
DLabel:SetIsMenu( boolean isMenu )
Used internally by DComboBox. Sets whether the frame is part of a derma menu or not. If this is set to true, CloseDermaMenus will not be called when the frame is clicked, and thus any open menus will remain open.
DLabel:SetIsToggle( boolean allowToggle )
Enables or disables toggle functionality for a label. Retrieved with DLabel:GetIsToggle. You must call this before using DLabel:SetToggle, DLabel:GetToggle or DLabel:Toggle.
DLabel:SetPaintBackground( boolean paint )
Sets whether or not the background should be painted. This is mainly used by derivative classes, such as DButton.
DLabel:SetTextColor( table color )
Sets the text color of the DLabel. This will take precedence over DLabel:SetTextStyleColor.
DLabel:SetTextStyleColor( table color )
This is used internally - although you're able to use it you probably shouldn't. Use DLabel:SetTextColor instead! Used by DLabel:SetDark, DLabel:SetBright and DLabel:SetHighlight to set the text color without affecting DLabel:SetTextColor calls.
DLabel:SetToggle( boolean toggleState )
Sets the toggle state of the label. This can be retrieved with DLabel:GetToggle and toggled with DLabel:Toggle. In order to use toggle functionality, you must first call DLabel:SetIsToggle with true, as it is disabled by default.
DLabel:Toggle()
Toggles the label's state. This can be set and retrieved with DLabel:SetToggle and DLabel:GetToggle. In order to use toggle functionality, you must first call DLabel:SetIsToggle with true, as it is disabled by default.
DLabel:UpdateColours( table skin )
A hook called from within PANEL:ApplySchemeSettings to determine the color of the text on display.
DLabel:UpdateFGColor()
This is used internally - although you're able to use it you probably shouldn't. Called internally to update the color of the text.

Example

Creates a DLabel.

local Panel = vgui.Create( "DFrame" ) Panel:SetSize( 200, 200 ) Panel:Center() Panel:MakePopup() local DLabel = vgui.Create( "DLabel", Panel ) DLabel:SetPos( 40, 40 ) DLabel:SetText( "Hello, world!" )
Output: