Panel/SetText

From Garry's Mod
Jump to: navigation, search
 Panel:SetText( )

Contents

Description

Sets the text value of a panel object containing text, such as a Label, TextEntry or RichText and their derivatives, such as DLabel, DTextEntry or DButton.

WARNING

When used on a Label or its derivatives ( DLabel and DButton ), it will automatically call Panel:InvalidateLayout, meaning that you should avoid running this function every frame on these panels to avoid unnecessary performance loss.

Arguments

string text

The text value to set.

Examples

Example

Creates a RichText element and sets the text to a localized string; the default VAC rejection message.

-- Window frame for the RichText
TextFrame = vgui.Create("DFrame")
TextFrame:SetSize(250, 150)
TextFrame:Center()
TextFrame:SetTitle("#VAC_ConnectionRefusedTitle") -- Results in "Connection Refused - VAC"

-- RichText panel
local richtext = vgui.Create("RichText", TextFrame)
richtext:Dock(FILL)

-- Set the text to the message you get when VAC banned
richtext:SetText("#VAC_ConnectionRefusedDetail")

Output:

RichText SetText example1.png
Personal tools
Navigation