Garry's Mod Wiki

Panel:SetBGColor

Panel:SetBGColor( number r or color, number g, number b, number a )

Description

Sets the background color of a panel such as a RichText, Label or DColorCube.

This doesn't apply to all VGUI elements and its function varies between them

For DLabel elements, you must use Panel:SetPaintBackgroundEnabled( true ) before applying the color.

This will not work on setup of the panel - you should use this function in a hook like PANEL:ApplySchemeSettings or PANEL:PerformLayout.

Arguments

1 number r or color
The red channel of the color, or a Color. If you pass the latter, the following three arguments are ignored.
2 number g
The green channel of the color.
3 number b
The blue channel of the color.
4 number a
The alpha channel of the color.

Example

Creates a RichText panel that mimics a blue screen of death.

-- Create a window frame TextFrame = vgui.Create("DFrame") TextFrame:SetSize(300, 100) TextFrame:Center() TextFrame:SetTitle("Windows XP Blue Screen") TextFrame:MakePopup() -- RichText panel local richtext = vgui.Create("RichText", TextFrame) richtext:Dock(FILL) -- Sample text richtext:SetText("A problem has been detected and Windows has been shut down to prevent damage to your computer.\n\nMOTHERBOARD_FRIED") -- When the panel is ready for layout, set the background color to blue function richtext:PerformLayout() self:SetBGColor(Color(0, 0, 255)) end
Output:

Page Links


Special Pages


Wikis

?

Render Time: 102ms

DB GetPage 55
Generate Html 17
SaveChanges (1) 9
Render Body 0
Render Sidebar 18