Garry's Mod Wiki

vgui

The vgui library allows you to script and create your own panels using Valve's Graphical User Interface (VGUI) system.

For an alphabetically ordered list of VGUI panels, see VGUI Element List.

Methods

Panel vgui.Create( string classname, Panel parent = nil, string name = "nil" )
Creates a panel by the specified classname. Custom VGUI elements are not loaded instantly. Use GM:OnGamemodeLoaded to create them on startup.
Panel vgui.CreateFromTable( table metatable, Panel parent = nil, string name = nil )
Creates a panel from a table, used alongside vgui. RegisterFile and vgui. RegisterTable to efficiently define, register, and instantiate custom panels.
Panel vgui.CreateX( string class, Panel parent = nil, string name = "nil" )
This is used internally - although you're able to use it you probably shouldn't. Creates an engine panel.
Returns whenever the cursor is currently active and visible.
boolean vgui.Exists( string Panelname )
Returns true if Lua-defined panel exists by name. Uses vgui. GetControlTable internally.
Returns whether the currently focused panel is a child of the given one.
table vgui.GetControlTable( string Panelname )
Returns the table of a Lua-defined panel by name. Does not return parent members of the table!
Returns the panel the cursor is hovering above. This returns a cached value that is only updated after rendering and before the next VGUI Think/Layout pass. ie. it lags one frame behind panel layout and is completely unhelpful for PANEL:Paint if your panels are moving around under the mouse a lot every frame.
Returns the panel which is currently receiving keyboard input.
Returns the global world panel which is the parent to all others, except for the HUD panel. See also GetHUDPanel.
Returns whenever the cursor is hovering the world panel.
table vgui.Register( string classname, table panelTable, string baseName = "Panel" )
Registers a panel for later creation via vgui. Create.
Registers a new VGUI panel from a file, to be used with vgui. CreateFromTable. File file must use the PANEL global that is provided just before the file is included, for example: PANEL. Base = "Panel" function PANEL:Init() -- Your code. . . end function PANEL:Think() -- Your code. . . end
table vgui.RegisterTable( table panel, string base = "Panel" )
Registers a table to use as a panel, to be used with vgui. CreateFromTable. All this function does is assigns Base key to your table and returns the table.