VGUI Label: Difference between revisions
m (Added Cleanup template (we need to clean the labelText attribute)) |
(Rewrite Template:Lang to Template:LanguageBar. This action was performed by a bot.) |
||
(14 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LanguageBar|VGUI Label}} | ||
{{ | {{cleanup}} | ||
'''VGUI Label''' is a VGUI control found in the vgui_controls library. Labels are useful for displaying small amounts of text. For displaying blocks or paragraphs of text, see [[VGUI RichText]]. | |||
= | == Object description == | ||
An object which displays text. It can additionally be used (in conjunction with a hotkey and the <code>associate</code> property set) to set the focus to the object named as the associated. | |||
Often used before [[VGUI TextEntry]] entries to tell the user what function the TextEntry has. | |||
== Availability == | |||
== | |||
This object is available in all Source games. | This object is available in all Source games. | ||
In code it is represented by class '''Label | In code it is represented by class '''Label''' (derived from class '''Panel'''), defined in <code>public/vgui_controls/Label.h</code> and contained in the namespace <code>vgui</code>. | ||
The source file is located at: <code>vgui2/controls/Label.cpp</code> | The source file is located at: <code>vgui2/controls/Label.cpp</code> | ||
Inherits from Panel. | Inherits from Panel. | ||
Text uses the control [[ | Text uses the control [[VGUI TextImage]] to render. | ||
== Keyvalues == | |||
*'''Font''' | *'''Font''' | ||
:<string> The font to render the text with | :<string> The font to render the text with. | ||
:Default: "Default" | :Default: "Default" | ||
:If given font is invalid, reverts to default. | :If given font is invalid, reverts to default. | ||
*'''labelText''' | *'''labelText''' | ||
:<string> The text to display | :<string> The text to display. | ||
:Default: NULL ("", empty string) | :Default: NULL ("", empty string) | ||
:Notes: | :Notes: | ||
<pre> | <pre> | ||
May be a localized string if starts with # | |||
Ex. "labelText" "#Title" | |||
If it contains an & the next character and the next only will be considered as a hotkey. If the next character is not usable it will continue parsing starting on the key AFTER the next. So, if it contains two consecutive &, it will fail, both will be disregarded and a third & would be the one that starts a new key lookup. The hotkey has to be alphanumeric. | If it contains an & the next character and the next only will be considered as a hotkey. If the next character is not usable it will | ||
continue parsing starting on the key AFTER the next. So, if it contains two consecutive &, it will fail, both will be disregarded | |||
and a third & would be the one that starts a new key lookup. The hotkey has to be alphanumeric. | |||
Ex. | |||
"labelText" "&a", a is hotkey | "labelText" "&a", a is hotkey | ||
"labelText" "&.a", no hotkey | "labelText" "&.a", no hotkey | ||
Line 43: | Line 42: | ||
"labelText" "&&&a&&b&c", a is hotkey | "labelText" "&&&a&&b&c", a is hotkey | ||
If the text is regular text it will lookup using isalnum() if it is localized (started with #) it will use iswalnum(). | If the text is regular text it will lookup using <code>isalnum()</code>, if it is localized (started with #) it will use <code>iswalnum()</code>. | ||
Hotkeys are automatically | Hotkeys are automatically lower-cased. They fire <code>OnHotkeyPressed()</code>. | ||
May be a localized variable if between '%'s | |||
Ex. "labelText" "%localize_me%" | |||
Will do: | |||
localize()->AddString( "var_%localize_me%", L"%localize_me%", "" ); | localize()->AddString( "var_%localize_me%", L"%localize_me%", "" ); | ||
Label->SetText( "#var_%localize_me%" ); | Label->SetText( "#var_%localize_me%" ); | ||
Line 57: | Line 55: | ||
*'''textAlignment''' | *'''textAlignment''' | ||
:<string> How the label is aligned | :<string> How the text within the label is aligned. | ||
:Default: "", -1, (unkown) | :Default: "", -1, (unkown) | ||
:Valid range: | :Valid range: | ||
Line 70: | Line 68: | ||
::*"south-east" | ::*"south-east" | ||
*''' | *'''associate''' | ||
:<string> The control this label is associated with. Will transfer control to this control when hotkey sequence is pressed. | :<string> The control this label is associated with. Will transfer control to this control when hotkey sequence is pressed. | ||
:Default: "" | :Default: "" | ||
Line 79: | Line 77: | ||
:Valid range: 0, 1 | :Valid range: 0, 1 | ||
:''If 1 sets colorstate CS_DULLTEXT'' | :''If 1 sets colorstate CS_DULLTEXT'' | ||
:{{note|If its value is 1 the entry '''brighttext''' will be skipped (if present).}} | |||
*'''brighttext''' | *'''brighttext''' | ||
:<integer> | :<integer> | ||
:Default: | :Default: 0 | ||
:Valid range: 0, 1 | :Valid range: 0, 1 | ||
:''If 1 sets colorstate CS_BRIGHTTEXT'' | :''If 1 sets colorstate CS_BRIGHTTEXT'' | ||
:'' | :{{note|Will be skipped if the entry '''dulltext''' is present and its value is 1.}} | ||
:{{note|The default colorstate for a Label is ''CS_NORMAL''}} | |||
*'''wrap''' | *'''wrap''' | ||
:<integer> Specifies | :<integer> Specifies whether or not to wrap the text to the next line if too long. | ||
:Default: 0 | :Default: 0 | ||
:Valid range: 0, 1 | :Valid range: 0, 1 | ||
[[Category:VGUI Controls|L]] | |||
[[Category: |
Latest revision as of 17:42, 18 July 2025

For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
VGUI Label is a VGUI control found in the vgui_controls library. Labels are useful for displaying small amounts of text. For displaying blocks or paragraphs of text, see VGUI RichText.
Object description
An object which displays text. It can additionally be used (in conjunction with a hotkey and the associate
property set) to set the focus to the object named as the associated.
Often used before VGUI TextEntry entries to tell the user what function the TextEntry has.
Availability
This object is available in all Source games.
In code it is represented by class Label (derived from class Panel), defined in public/vgui_controls/Label.h
and contained in the namespace vgui
.
The source file is located at: vgui2/controls/Label.cpp
Inherits from Panel. Text uses the control VGUI TextImage to render.
Keyvalues
- Font
- <string> The font to render the text with.
- Default: "Default"
- If given font is invalid, reverts to default.
- labelText
- <string> The text to display.
- Default: NULL ("", empty string)
- Notes:
May be a localized string if starts with # Ex. "labelText" "#Title" If it contains an & the next character and the next only will be considered as a hotkey. If the next character is not usable it will continue parsing starting on the key AFTER the next. So, if it contains two consecutive &, it will fail, both will be disregarded and a third & would be the one that starts a new key lookup. The hotkey has to be alphanumeric. Ex. "labelText" "&a", a is hotkey "labelText" "&.a", no hotkey "labelText" "&.&a", a is hotkey "labelText" "&a&b", a is hotkey "labelText" "&&a", no hotkey "labelText" "&&&a&&b&c", a is hotkey If the text is regular text it will lookup using <code>isalnum()</code>, if it is localized (started with #) it will use <code>iswalnum()</code>. Hotkeys are automatically lower-cased. They fire <code>OnHotkeyPressed()</code>. May be a localized variable if between '%'s Ex. "labelText" "%localize_me%" Will do: localize()->AddString( "var_%localize_me%", L"%localize_me%", "" ); Label->SetText( "#var_%localize_me%" );
- textAlignment
- <string> How the text within the label is aligned.
- Default: "", -1, (unkown)
- Valid range:
- "north-west"
- "north"
- "north-east"
- "west"
- "center"
- "east"
- "south-west"
- "south"
- "south-east"
- associate
- <string> The control this label is associated with. Will transfer control to this control when hotkey sequence is pressed.
- Default: ""
- dulltext
- <integer>
- Default: 0
- Valid range: 0, 1
- If 1 sets colorstate CS_DULLTEXT
Note:If its value is 1 the entry brighttext will be skipped (if present).
- brighttext
- <integer>
- Default: 0
- Valid range: 0, 1
- If 1 sets colorstate CS_BRIGHTTEXT
Note:Will be skipped if the entry dulltext is present and its value is 1.
Note:The default colorstate for a Label is CS_NORMAL
- wrap
- <integer> Specifies whether or not to wrap the text to the next line if too long.
- Default: 0
- Valid range: 0, 1