Garry's Mod Wiki


The vgui library allows you to script and create your own panels using Valve's GUI system.
For an alphabetically ordered list of VGUI panels, see VGUI Element List.


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 table. Typically used with vgui. RegisterFile and vgui. RegisterTable.
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.
boolean vgui.CursorVisible()
Returns whenever the cursor is currently active and visible.
boolean vgui.FocusedHasParent( Panel parent )
Returns whether the currently focused panel is a child of the given one.
table vgui.GetControlTable( string Panelname )
Gets the method table of this panel. Does not return parent methods!
Panel vgui.GetHoveredPanel()
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.
Panel vgui.GetKeyboardFocus()
Returns the panel which is currently receiving keyboard input.
Panel vgui.GetWorldPanel()
Returns the global world panel which is the parent to all others, except for the HUD panel. See also GetHUDPanel.
boolean vgui.IsHoveringWorld()
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.
table vgui.RegisterFile( string file )
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.