VGUI Label: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
(Updated to conform to VGUI Controls look)
Line 1: Line 1:
{{stub}}
{{stub}}


Uses font "Default" if font is invalid.
=VGUI Label=
 
==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.
 
==Availibility==
This object is available in all Source games.
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>


Inherits from Panel.
Inherits from Panel.
Text uses the control TextImage to render.
Text uses the control [[VGUI_TextImage]] to render.
 
--


==Keyvalues==


"labelText" text
*'''Font'''
defaults NULL = ""
:<string> The font to render the text with
:Default: "Default"
:If given font is invalid, reverts to default.


may be a localized string if starts with #
*'''labelText'''
:<string> The text to display
:Default: NULL ("", empty string)
:Notes:
<pre>may be a localized string if starts with #
ex. "labelText" "#Title"
ex. "labelText" "#Title"


Line 36: Line 53:
  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%" );
</pre>


--
*'''textAlignment'''
 
:<string> How the label is aligned
"textAlignment" text
:Default: "", -1, (unkown)
default "" = -1
:Valid range:
 
::*"north-west"
values:
::*"north"
"north-west"
::*"north-east"
"north"
::*"west"
"north-east"
::*"center"
"west"
::*"east"
"center"
::*"south-west"
"east"
::*"south"
"south-west"
::*"south-east"
"south"
"south-east"
 
--
 
"associate" controlname
 
associated control default ""
 
--
 
"dulltext" 0/1
 
defaults 0, if 1 sets colorstate CS_DULLTEXT
 
if 0:
 
"brighttext" 0/1
 
defaults 1, if 1 sets colorstate CS_BRIGHTTEXT
 
if 0:
 
sets colorstate CS_NORMAL
 
--


"font" script fontname
*'''"associate"'''
defaults "" = "Default"
:<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''


"wrap" 0/1
*'''brighttext'''
:<integer>
:Default: 1
:Valid range: 0, 1
:''If 1 sets colorstate CS_BRIGHTTEXT''
:''If 0 sets colorstate CS_NORMAL''


text wrap
*'''wrap'''
:<integer> Specifies wether or not to wrap the text to the next line if too long
:Default: 0
:Valid range: 0, 1




[[Category:VGUI_Controls]]
[[Category:VGUI_Controls]]

Revision as of 04:58, 6 January 2007

Stub

This article or section is a stub. You can help by expanding it.

VGUI Label

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.

Availibility

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 isalnum() if it is localized (started with #) it will use iswalnum().

Hotkeys are automatically lowercased. They fire OnHotkeyPressed().



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 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
  • brighttext
<integer>
Default: 1
Valid range: 0, 1
If 1 sets colorstate CS_BRIGHTTEXT
If 0 sets colorstate CS_NORMAL
  • wrap
<integer> Specifies wether or not to wrap the text to the next line if too long
Default: 0
Valid range: 0, 1