Panel/SetWrap

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

Contents

Description

Sets whether text wrapping should be enabled or disabled on Label and DLabel panels. Use DLabel:SetAutoStretchVertical to automatically correct vertical size; Panel:SizeToContents will not set the correct height.

Arguments

boolean wrap

True to enable text wrapping, false otherwise.

Examples

Example

Creates two labels in a panel and sets the text wrapping to false and true respectively.

-- Background panel
BGPanel = vgui.Create("DPanel")
BGPanel:SetSize(300, 130)
BGPanel:Center()
BGPanel:SetBackgroundColor(Color(0, 0, 0))
		
-- Label with no text wrapping
local lbl_nowrap = vgui.Create("DLabel", BGPanel)
lbl_nowrap:SetPos(10, 10)
lbl_nowrap:SetSize(280, 50)		
lbl_nowrap:SetFont("GModNotify")
lbl_nowrap:SetText("This is a label that has text wrapping disabled.")

lbl_nowrap:SetWrap(false)

-- Label with text wrapping
local lbl_wrap = vgui.Create("DLabel", BGPanel)
lbl_wrap:SetPos(10, 70)
lbl_wrap:SetSize(280, 50)
lbl_wrap:SetFont("GModNotify")
lbl_wrap:SetText("This is a label that has text wrapping enabled.")

lbl_wrap:SetWrap(true)

Output:



Panel SetWrap example1.png
Personal tools
Navigation