Garry's Mod Wiki

Panel

Description

This is the base panel for every other VGUI panel.

It contains all of the basic methods, some of which may only work on certain VGUI elements. As their functionality is provided at the game's C/C++ level rather than by its Lua script extension, they are unfortunately unavailable for most practical purposes, however, they can still be obtained in a way similar to that provided by the baseclass library:

-- Create a new panel type NewPanel that inherits all of its functionality from DLabel, -- but has a different SetText method than DLabel does - all without the hassle of that -- old DLabel's default text getting in the way. Fun stuff. local PANEL = {} function PANEL:Init() self:SetText_Base( "" ) self:SetText( "Time for something different!" ) end function PANEL:Paint( aWide, aTall ) local TextX, TextY = 0, 0 local TextColor = Color( 255, 0, 0, 255 ) surface.SetFont( self:GetFont() or "default" ) surface.SetTextColor( TextColor ) surface.SetTextPos( TextX, TextY ) surface.DrawText( self:GetText() ) end -- And here we go: PANEL.SetText_Base = FindMetaTable( "Panel" ).SetText function PANEL:SetText( aText ) self.Text = tostring( aText ) end function PANEL:GetText() return self.Text or "" end vgui.Register( "NewPanel", PANEL, "DLabel" )

Methods

Panel Panel:Add( Panel object )
Adds the specified object to the panel.
Panel:AddText()
We advise against using this. It may be changed or removed in a future update. Does nothing This function does nothing.
Panel:AlignBottom( number offset = 0 )
Aligns the panel on the bottom of its parent with the specified offset.
Panel:AlignLeft( number offset = 0 )
Aligns the panel on the left of its parent with the specified offset.
Panel:AlignRight( number offset = 0 )
Aligns the panel on the right of its parent with the specified offset.
Panel:AlignTop( number offset = 0 )
Aligns the panel on the top of its parent with the specified offset.
Panel:AlphaTo( number alpha, number duration, number delay = 0, function callback )
Uses animation to transition the current alpha value of a panel to a new alpha, over a set period of time and after a specified delay.
Panel:AnimationThinkInternal()
This is used internally - although you're able to use it you probably shouldn't. Performs the per-frame operations required for panel animations. This is called every frame by PANEL:AnimationThink.
number Panel:AnimTail()
Returns the SysTime value when all animations for this panel object will end.
Panel:AppendText( string txt )
Appends text to a RichText element. This does not automatically add a new line.
Panel:ApplyGWEN( table GWENTable )
Used by Panel:LoadGWENFile and Panel:LoadGWENString to apply a GWEN controls table to a panel object. You can do this manually using file.Read and util.JSONToTable to import and create a GWEN table structure from a .gwen file. This method can then be called, passing the GWEN table's Controls member.
Panel:Center()
Centers the panel on its parent.
Panel:CenterHorizontal( number fraction = 0.5 )
Centers the panel horizontally with specified fraction.
Panel:CenterVertical( number fraction = 0.5 )
Centers the panel vertically with specified fraction.
number Panel:ChildCount()
Returns the amount of children of the of panel.
number, number Panel:ChildrenSize()
Returns the width and height of the space between the position of the panel (upper-left corner) and the max bound of the children panels (farthest reaching lower-right corner).
Panel:Clear()
Marks all of the panel's children for deletion.
Panel:ColorTo( table color, number length, number delay, function callback )
Fades panels color to specified one. It won't work unless panel has SetColor function.
Panel:Command( string command )
Sends an action command signal to the panel. The response is handled by PANEL:ActionSignal.
Panel:ConVarChanged( string newValue )
Updates a panel object's associated console variable. This must first be set up with Derma_Install_Convar_Functions, and have a ConVar set using Panel:SetConVar.
Panel:ConVarNumberThink()
A think hook for Panels using ConVars as a value. Call it in the Think hook. Sets the panel's value should the convar change. This function is best for: checkboxes, sliders, number wangs For a string alternative, see Panel:ConVarStringThink. Important: Make sure your Panel has a SetValue function, else you may get errors.
Panel:ConVarStringThink()
A think hook for panels using ConVars as a value. Call it in the Think hook. Sets the panel's value should the convar change. This function is best for: text inputs, read-only inputs, dropdown selects For a number alternative, see Panel:ConVarNumberThink. Important: Make sure your Panel has a SetValue function, else you may get errors.
Panel:CopyBase( Panel srcPanel )
Gets the size, position and dock state of the passed panel object, and applies it to this one.
Panel:CopyBounds( Panel base )
Copies position and size of the panel.
Panel:CopyHeight( Panel base )
Copies the height of the panel.
Panel:CopyPos( Panel base )
Copies the position of the panel.
Panel:CopySelected()
Performs the "CONTROL + C" key combination effect ( Copy selection to clipboard ) on selected text.
Panel:CopyWidth( Panel base )
Copies the width of the panel.
number, number Panel:CursorPos()
Returns the cursor position relative to the top left of the panel. This is equivalent to calling gui.MousePos and then Panel:ScreenToLocal. This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass. ie. inaccurate results may be returned if the panel or any of its ancestors have been repositioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.
Panel:CutSelected()
Performs the "CONTROL + X" ( delete text and copy it to clipboard buffer ) action on selected text.
Panel:DeleteCookie( string cookieName )
Deletes a cookie value using the panel's cookie name ( Panel:GetCookieName ) and the passed extension.
Panel:DisableLerp()
Resets the panel object's Panel:SetPos method and removes its animation table (Panel.LerpAnim). This effectively undoes the changes made by Panel:LerpPositions. In order to use Lerp animation again, you must call Panel:Stop before setting its SetPosReal property to 'nil'. See the example below.
number Panel:Distance( Panel tgtPanel )
Returns the linear distance from the center of this panel object and another. Both panels must have the same parent for this function to work properly.
number Panel:DistanceFrom( number posX, number posY )
Returns the distance between the center of this panel object and a specified point local to the parent panel.
Panel:Dock( number dockType )
Sets the dock type for the panel, making the panel "dock" in a certain direction, modifying it's position and size. You can set the inner spacing of a panel's docking using Panel:DockPadding, which will affect docked child panels, and you can set the outer spacing of a panel's docking using Panel:DockMargin, which affects how docked siblings are positioned/sized. After using this function, if you want to get the correct panel's bounds (position, size), use Panel:InvalidateParent (use true as arg..
Panel:DockMargin( number marginLeft, number marginTop, number marginRight, number marginBottom )
Sets the dock margin of the panel. The dock margin is the extra space that will be left around the edge when this element is docked inside its parent element.
Panel:DockPadding( number paddingLeft, number paddingTop, number paddingRight, number paddingBottom )
Sets the dock padding of the panel. The dock padding is the extra space that will be left around the edge when child elements are docked inside this element.
Panel:DoModal()
Makes the panel "lock" the screen until it is removed. All input will be directed to the given panel. It will silently fail if used while cursor is not visible. Call Panel:MakePopup before calling this function. This must be called on a panel derived from EditablePanel. You can still click in the world even if locked.Issue Tracker: 3457
boolean Panel:DragClick()
This is used internally - although you're able to use it you probably shouldn't. Called by Panel:DragMouseRelease when a user clicks one mouse button whilst dragging with another.
Panel:DragHover( number HoverTime )
This is used internally - although you're able to use it you probably shouldn't. Called by dragndrop.HoverThink to perform actions on an object that is dragged and hovered over another.
Panel:DragHoverEnd()
This is used internally - although you're able to use it you probably shouldn't. Called to end a drag and hover action. This resets the panel's PANEL:PaintOver method, and is primarily used by dragndrop.StopDragging.
Panel:DragMousePress( number mouseCode )
Called to inform the dragndrop that a mouse button is being held down on a panel object.
boolean Panel:DragMouseRelease( number mouseCode )
Called to inform the dragndrop that a mouse button has been depressed on a panel object.
Panel:DrawDragHover( number x, number y, number width, number height )
This is used internally - although you're able to use it you probably shouldn't. Called to draw the drop target when an object is being dragged across another. See Panel:SetDropTarget.
Panel:DrawFilledRect()
Draws a coloured rectangle to fill the panel object this method is called on. The colour is set using surface.SetDrawColor. This should only be called within the object's PANEL:Paint or PANEL:PaintOver hooks, as a shortcut for surface.DrawRect.
Panel:DrawOutlinedRect()
Draws a hollow rectangle the size of the panel object this method is called on, with a border width of 1 px. The border colour is set using surface.SetDrawColor. This should only be called within the object's PANEL:Paint or PANEL:PaintOver hooks, as a shortcut for surface.DrawOutlinedRect.
Panel:DrawSelections()
Used to draw the magenta highlight colour of a panel object when it is selected. This should be called in the object's PANEL:PaintOver hook. Once this is implemented, the highlight colour will be displayed only when the object is selectable and selected. This is achieved using Panel:SetSelectable and Panel:SetSelected respectively.
Panel:DrawTextEntryText( table textCol, table highlightCol, table cursorCol )
Used to draw the text in a DTextEntry within a derma skin. This should be called within the SKIN:PaintTextEntry skin hook. Will silently fail if any of arguments are not Color.
Panel:DrawTexturedRect()
Draws a textured rectangle to fill the panel object this method is called on. The texture is set using surface.SetTexture or surface.SetMaterial. This should only be called within the object's PANEL:Paint or PANEL:PaintOver hooks, as a shortcut for surface.DrawTexturedRect.
table Panel:Droppable( string name )
Makes this panel droppable. This is used with Panel:Receiver to create drag and drop events. Can be called multiple times with different names allowing to be dropped onto different receivers.
boolean Panel:EndBoxSelection()
Completes a box selection. If the end point of the selection box is within the selection canvas, mouse capture is disabled for the panel object, and the selected state of each child object within the selection box is toggled.
Panel:Exec( string cmd )
This is used internally - although you're able to use it you probably shouldn't. Used to run commands within a DHTML window.
Panel Panel:Find( string panelName )
Finds a panel in its children(and sub children) with the given name.
Panel:FocusNext()
Focuses the next panel in the focus queue.
Panel:FocusPrevious()
Focuses the previous panel in the focus queue.
number Panel:GetAlpha()
Returns the alpha multiplier for this panel.
number Panel:GetBGColor()
Returns 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
number, number, number, number Panel:GetBounds()
Returns the position and size of the panel. This is equivalent to calling Panel:GetPos and Panel:GetSize together.
number Panel:GetCaretPos()
Returns the position/offset of the caret (or text cursor) in a text-based panel object.
Panel:GetChild( number childIndex )
Gets a child by its index.
number, number Panel:GetChildPosition( Panel pnl )
Gets a child object's position relative to this panel object. The number of levels is not relevant; the child may have many parents between itself and the object on which the method is called.
table Panel:GetChildren()
Returns a table with all the child panels of the panel.
table Panel:GetChildrenInRect( number x, number y, number w, number h )
Returns a table of all visible, selectable children of the panel object that lie at least partially within the specified rectangle.
string Panel:GetClassName()
Returns the class name of the panel.
Panel, number Panel:GetClosestChild( number x, number y )
Returns the child of this panel object that is closest to the specified point. The point is relative to the object on which the method is called. The distance the child is from this point is also returned.
number, number Panel:GetContentSize()
Gets the size of the content/children within a panel object. Only works with Label derived panels by default such as DLabel. Will also work on any panel that manually implements this method.
string Panel:GetCookie( string cookieName, string default )
Gets the value of a cookie stored by the panel object. This can also be done with cookie.GetString, using the panel's cookie name, a fullstop, and then the actual name of the cookie. Make sure the panel's cookie name has not changed since writing, or the cookie will not be accessible. This can be done with Panel:GetCookieName and Panel:SetCookieName.
string Panel:GetCookieName()
Gets the name the panel uses to store cookies. This is set with Panel:SetCookieName.
number Panel:GetCookieNumber( string cookieName, number default )
Gets the value of a cookie stored by the panel object, as a number. This can also be done with cookie.GetNumber, using the panel's cookie name, a fullstop, and then the actual name of the cookie. Make sure the panel's cookie name has not changed since writing, or the cookie will not be accessible. This can be done with Panel:GetCookieName and Panel:SetCookieName.
number Panel:GetDock()
Returns a dock enum for the panel's current docking type.
number, number, number, number Panel:GetDockMargin()
Returns the docked margins of the panel. (set by Panel:DockMargin)
number, number, number, number Panel:GetDockPadding()
Returns the docked padding of the panel. (set by Panel:DockPadding)
table Panel:GetFGColor()
Returns the foreground color of the panel. For a Label or RichText, this is the color of its text. This doesn't apply to all VGUI elements (such as DLabel) and its function varies between them
string Panel:GetFont()
Returns the name of the font that the panel renders its text with. This is the same font name set with Panel:SetFontInternal.
IMaterial Panel:GetHTMLMaterial()
Returns the panel's HTML material. Only works with Awesomium, HTML and DHTML panels that have been fully loaded.
number Panel:GetMaximumCharCount()
Returns the current maximum character count. This function will only work on RichText and TextEntry panels and their derivatives.
string Panel:GetName()
Returns the internal name of the panel.
number Panel:GetNumLines()
Returns the number of lines in a RichText. You must wait a couple frames before calling this after using Panel:AppendText or Panel:SetText, otherwise it will return the number of text lines before the text change. Even though this function can be called on any panel, it will only work with RichText
Panel Panel:GetParent()
Returns the parent of the panel, returns nil if there is no parent.
number, number Panel:GetPos()
Returns the position of the panel relative to its Panel:GetParent. If you require the panel's position and size, consider using Panel:GetBounds instead. If you need the position in screen space, see Panel:LocalToScreen.
table Panel:GetSelectedChildren()
Returns a table of all children of the panel object that are selected. This is recursive, and the returned table will include tables for any child objects that also have children. This means that not all first-level members in the returned table will be of type Panel.
number, number Panel:GetSelectedTextRange()
Returns the currently selected range of text. This function will only work on RichText and TextEntry panels and their derivatives.
Panel Panel:GetSelectionCanvas()
Returns the panel object (self) if it has been enabled as a selection canvas. This is achieved using Panel:SetSelectionCanvas.
number, number Panel:GetSize()
Returns the size of the panel. If you require both the panel's position and size, consider using Panel:GetBounds instead.
table Panel:GetSkin()
Returns the table for the derma skin currently being used by this panel object.
table Panel:GetTable()
Returns the internal Lua table of the panel.
number Panel:GetTall()
Returns the height of the panel.
string Panel:GetText()
Returns the panel's text (where applicable). This method returns a maximum of 1023 bytes, except for DTextEntry.
number, number Panel:GetTextInset()
Gets the left and top text margins of a text-based panel object, such as a DButton or DLabel. This is set with Panel:SetTextInset.
number, number Panel:GetTextSize()
Gets the size of the text within a Label derived panel. This can return 0 incorrectly.Issue Tracker: 2576
Panel, table Panel:GetValidReceiverSlot()
Gets valid receiver slot of currently dragged panel.
any Panel:GetValue()
Returns the value the panel holds. In engine is only implemented for CheckButton, Label and TextEntry as a string. This function is limited to 8092 Bytes. If using DTextEntry, use Panel:GetText for unlimited bytes.
number Panel:GetWide()
Returns the width of the panel.
number Panel:GetZPos()
Returns the Z position of the panel.
Panel:GoBack()
Goes back one page in the HTML panel's history if available.
Panel:GoForward()
Goes forward one page in the HTML panel's history if available.
Panel:GoToHistoryOffset( number offset )
Goes to the page in the HTML panel's history at the specified relative offset.
Panel:GotoTextEnd()
Causes a RichText element to scroll to the bottom of its text.
Panel:GotoTextStart()
Causes a RichText element to scroll to the top of its text. This does not work on the same frame as Panel:SetText.Issue Tracker: 2239
Panel:GWEN_SetCheckboxText( string txt )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the CheckboxText property to a DCheckBoxLabel. This does exactly the same as Panel:GWEN_SetText, but exists to cater for the seperate GWEN properties.
Panel:GWEN_SetControlName( string name )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the ControlName property to a panel. This calls Panel:SetName.
Panel:GWEN_SetDock( string dockState )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Dock property to a panel object. This calls Panel:Dock.
Panel:GWEN_SetHorizontalAlign( string hAlign )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the HorizontalAlign property to a panel object. This calls Panel:SetContentAlignment.
Panel:GWEN_SetMargin( table margins )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Margin property to a panel object. This calls Panel:DockMargin.
Panel:GWEN_SetMax( number maxValue )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Max property to a DNumberWang, Slider, DNumSlider or DNumberScratch. This calls SetMax on one of the previously listed methods.
Panel:GWEN_SetMin( number minValue )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Min property to a DNumberWang, Slider, DNumSlider or DNumberScratch. This calls SetMin on one of the previously listed methods.
Panel:GWEN_SetPosition( table pos )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Position property to a panel object. This calls Panel:SetPos.
Panel:GWEN_SetSize( table size )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Size property to a panel object. This calls Panel:SetSize.
Panel:GWEN_SetText( string txt )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Text property to a panel.
boolean Panel:HasChildren()
Returns whenever the panel has child panels.
boolean Panel:HasFocus()
Returns if the panel is focused.
boolean Panel:HasHierarchicalFocus()
Returns if the panel or any of its children(sub children and so on) has the focus.
boolean Panel:HasParent( Panel parentPanel )
Returns whether the panel is a descendent of the given panel.
Panel:Hide()
Makes a panel invisible.
Panel:InsertClickableTextEnd()
Marks the end of a clickable text segment in a RichText element, started with Panel:InsertClickableTextStart.
Panel:InsertClickableTextStart( string signalValue )
Starts the insertion of clickable text for a RichText element. Any text appended with Panel:AppendText between this call and Panel:InsertClickableTextEnd will become clickable text. The hook PANEL:ActionSignal is called when the text is clicked, with "TextClicked" as the signal name and signalValue as the signal value. The clickable text is a separate Derma panel which will not inherit the current font from the RichText.
Panel:InsertColorChange( number r, number g, number b, number a )
Inserts a color change in a RichText element, which affects the color of all text added with Panel:AppendText until another color change is applied.
Panel:InsertFade( number sustain, number length )
Begins a text fade for a RichText element where the last appended text segment is fully faded out after a specific amount of time, at a specific speed. The alpha of the text at any given time is determined by the text's base alpha * ((sustain - CurTime) / length) where CurTime is added to sustain when this method is called.
Panel:InvalidateChildren( boolean recursive = false )
Invalidates the layout of this panel object and all its children. This will cause these objects to re-layout immediately, calling PANEL:PerformLayout. If you want to perform the layout in the next frame, you will have loop manually through all children, and call Panel:InvalidateLayout on each.
Panel:InvalidateLayout( boolean layoutNow = false )
Causes the panel to re-layout in the next frame. During the layout process PANEL:PerformLayout will be called on the target panel. You should avoid calling this function every frame. Using this on a panel after clicking on a docked element will cause docked elements to reorient themselves incorrectly. This can be fixed by assigning a unique Panel:SetZPos to each docked element.Issue Tracker: 2574
Panel:InvalidateParent( boolean layoutNow = false )
Invalidates the layout of the parent of this panel object. This will cause it to re-layout, calling PANEL:PerformLayout.
boolean Panel:IsChildHovered( boolean immediate = false )
Determines whether the mouse cursor is hovered over one of this panel object's children. This is a reverse process using vgui.GetHoveredPanel, and looks upward to find the parent.
boolean Panel:IsDraggable()
Returns whether this panel is draggable ( if user is able to drag it ) or not.
boolean Panel:IsDragging()
Returns whether this panel is currently being dragged or not.
boolean Panel:IsEnabled()
Returns whether the the panel is enabled or disabled. See Panel:SetEnabled for a function that makes the panel enabled or disabled.
boolean Panel:IsHovered()
Returns whether the mouse cursor is hovering over this panel or not Uses vgui.GetHoveredPanel internally. Requires Panel:SetMouseInputEnabled to be set to true.
boolean Panel:IsKeyboardInputEnabled()
Returns true if the panel can receive keyboard input.
boolean Panel:IsLoading()
Determines whether or not a HTML or DHTML element is currently loading a page. Before calling Panel:SetHTML or DHTML:OpenURL, the result seems to be false with the Awesomium web renderer and true for the Chromium web renderer. This difference can be used to determine the available HTML5 capabilities.On Awesomium, the result remains true until the root document is loaded and when in-page content is loading (when adding pictures, frames, etc.). During this state, the HTML texture is not refreshed and the pa..
boolean Panel:IsMarkedForDeletion()
Returns if the panel is going to be deleted in the next frame.
boolean Panel:IsMouseInputEnabled()
Returns true if the panel can receive mouse input.
boolean Panel:IsOurChild( Panel childPanel )
Returns whether the panel contains the given panel, recursively.
boolean Panel:IsSelectable()
Determines if the panel object is selectable (like icons in the Spawn Menu, holding ⇧ shift). This is set with Panel:SetSelectable.
boolean Panel:IsSelected()
Returns if the panel object is selected (like icons in the Spawn Menu, holding ⇧ shift). This can be set in Lua using Panel:SetSelected.
any Panel:IsSelectionCanvas()
Determines if the panel object is a selection canvas or not. This is set with Panel:SetSelectionCanvas.
boolean Panel:IsValid()
Returns if the panel is valid and not marked for deletion.
boolean Panel:IsVisible()
Returns if the panel is visible.
boolean Panel:IsWorldClicker()
Returns if a panel allows world clicking set by Panel:SetWorldClicker.
Panel:KillFocus()
Remove the focus from the panel.
Panel:LerpPositions( number speed, boolean easeOut )
Redefines the panel object's Panel:SetPos method to operate using frame-by-frame linear interpolation (Lerp). When the panel's position is changed, it will move to the target position at the speed defined. You can undo this with Panel:DisableLerp. Unlike the other panel animation functions, such as Panel:MoveTo, this animation method will not operate whilst the game is paused. This is because it relies on FrameTime.
Panel:LoadControlsFromFile( string path )
We advise against using this. It may be changed or removed in a future update.This is used internally - although you're able to use it you probably shouldn't. Similar to Panel:LoadControlsFromString but loads controls from a file.
Panel:LoadControlsFromString( string data )
We advise against using this. It may be changed or removed in a future update.This is used internally - although you're able to use it you probably shouldn't. Loads controls(positions, etc) from given data. This is what the default options menu uses.
Panel:LoadGWENFile( string filename, string path = "GAME" )
Loads a .gwen file (created by GWEN Designer) and calls Panel:LoadGWENString with the contents of the loaded file. Used to load panel controls from a file.
Panel:LoadGWENString( string str )
Loads controls for the panel from a JSON string.
Panel:LoadTGAImage( string imageName, string strPath )
Sets a new image to be loaded by a TGAImage.
number, number Panel:LocalCursorPos()
Returns the cursor position local to the position of the panel (usually the upper-left corner).
number, number Panel:LocalToScreen( number posX, number posY )
Gets the absolute screen position of the position specified relative to the panel. See also Panel:ScreenToLocal. This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass, so inaccurate results may be returned if the panel or any of its ancestors have been re-positioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.If the panel uses Panel:Dock, this function will return 0, 0 when the panel was created. The position..
Panel:MakePopup()
Focuses the panel and enables it to receive input. This automatically calls Panel:SetMouseInputEnabled and Panel:SetKeyboardInputEnabled and sets them to true. Panels derived from Panel will not work properly with this function. Due to this, any children will not be intractable with keyboard. Derive from EditablePanel instead. For non gui related mouse focus, you can use gui.EnableScreenClicker.
Panel:MouseCapture( boolean doCapture )
Allows the panel to receive mouse input even if the mouse cursor is outside the bounds of the panel.
Panel:MoveAbove( Panel panel, number offset = 0 )
Places the panel above the passed panel with the specified offset.
Panel:MoveBelow( Panel panel, number offset = 0 )
Places the panel below the passed panel with the specified offset.
Panel:MoveBy( number moveX, number moveY, number time, number delay = 0, number ease = -1, function callback = nil )
Moves the panel by the specified coordinates using animation.
Panel:MoveLeftOf( Panel panel, number offset = 0 )
Places the panel left to the passed panel with the specified offset.
Panel:MoveRightOf( Panel panel, number offset = 0 )
Places the panel right to the passed panel with the specified offset.
Panel:MoveTo( number posX, number posY, number time, number delay = 0, number ease = -1, function callback )
Moves the panel to the specified position using animation. Setting the ease argument to 0 will result in the animation happening instantly, this applies to all MoveTo/SizeTo functions
boolean Panel:MoveToAfter( Panel siblingPanel )
Moves this panel object in front of the specified sibling (child of the same parent) in the render order, and shuffles up the Z-positions of siblings now behind.
Panel:MoveToBack()
Moves the panel object behind all other panels on screen. If the panel has been made a pop-up with Panel:MakePopup, it will still draw in front of any panels that haven't.
boolean Panel:MoveToBefore( Panel siblingPanel )
Moves this panel object behind the specified sibling (child of the same parent) in the render order, and shuffles up the Panel:SetZPos of siblings now in front.
Panel:MoveToFront()
Moves the panel in front of all other panels on screen. Unless the panel has been made a pop-up using Panel:MakePopup, it will still draw behind any that have.
table Panel:NewAnimation( number length, number delay = 0, number ease = -1, function callback = nil )
Creates a new animation for the panel object. Methods that use this function: Panel:MoveTo Panel:SizeTo Panel:SlideUp Panel:SlideDown Panel:ColorTo Panel:AlphaTo Panel:MoveBy Panel:LerpPositions
Panel:NewObject( string objectName )
This is used internally - although you're able to use it you probably shouldn't.
Panel:NewObjectCallback( string objectName, string callbackName )
This is used internally - although you're able to use it you probably shouldn't.
Panel:NoClipping( boolean clip )
Sets whether this panel's drawings should be clipped within the parent panel's bounds. See also DisableClipping.
number Panel:NumSelectedChildren()
Returns the number of children of the panel object that are selected. This is equivalent to calling Panel:IsSelected on all child objects and counting the number of returns that are true.
Panel:PaintAt( number posX, number posY )
Paints a ghost copy of the panel at the given position.
Panel:PaintManual()
Paints the panel at its current position. To use this you must call Panel:SetPaintedManually(true).
Panel:ParentToHUD()
Parents the panel to the HUD. Makes it invisible on the escape-menu and disables controls.
Panel:Paste()
Due to privacy concerns, this function has been disabled Only works for TextEntries. Pastes the contents of the clipboard into the TextEntry. Tab characters will be dropped from the pasted text
number Panel:PositionLabel( number lblWidth, number x, number y, Panel lbl, Panel panelObj )
Sets the width and position of a DLabel and places the passed panel object directly to the right of it. Returns the y value of the bottom of the tallest object. The panel on which this method is run is not relevant; only the passed objects are affected.
Panel:PostMessage( string messageName, string valueType, string value )
We advise against using this. It may be changed or removed in a future update. Only used in deprecated Derma controls. Sends a command to the panel.
Panel:Prepare()
This is used internally - although you're able to use it you probably shouldn't. Installs Lua defined functions into the panel.
Panel:Queue()
Enables the queue for panel animations. If enabled, the next new animation will begin after all current animations have ended. This must be called before Panel:NewAnimation to work, and only applies to the next new animation. If you want to queue many, you must call this before each.
Panel:RebuildSpawnIcon()
Causes a SpawnIcon to rebuild its model image.
Panel:RebuildSpawnIconEx( table data )
Re-renders a spawn icon with customized cam data. PositionSpawnIcon can be used to easily calculate the necessary camera parameters. This function does not accept the standard Structures/CamData.
Panel:Receiver( string name, function func, table menu )
Allows the panel to receive drag and drop events. Can be called multiple times with different names to receive multiple different draggable panel events.
Panel:Refresh( boolean ignoreCache = false )
Refreshes the HTML panel's current page.
Panel:Remove()
Marks a panel for deletion so it will be deleted on the next frame. This will not mark child panels for deletion this frame, but they will be marked and deleted in the next frame. See also Panel:IsMarkedForDeletion Will automatically call Panel:InvalidateParent.
Panel:RequestFocus()
Attempts to obtain focus for this panel.
Panel:ResetAllFades( boolean hold, boolean expiredOnly, number newSustain )
Resets all text fades in a RichText element made with Panel:InsertFade.
Panel:RunJavascript( string js )
Runs/Executes a string as JavaScript code in a panel. This function does NOT evaluate expression (i.e. allow you to pass variables from JavaScript (JS) to Lua context).Because a return value is nil/no value (a.k.a. void).If you wish to pass/return values from JS to Lua, you may want to use DHTML:AddFunction function to accomplish that job.The Awesomium web renderer automatically delays the code execution if the document is not ready, but the Chromium web renderer does not! This means that with Chromium, y..
Panel:SaveUndoState()
Saves the current state (caret position and the text inside) of a TextEntry as an undo state. See also Panel:Undo.
number, number Panel:ScreenToLocal( number screenX, number screenY )
Translates global screen coordinate to coordinates relative to the panel. See also Panel:LocalToScreen. This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass, so inaccurate results may be returned if the panel or any of its ancestors have been re-positioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.
Panel:SelectAll()
Selects all items within a panel or object. For text-based objects, selects all text.
Panel:SelectAllOnFocus()
If called on a text entry, clicking the text entry for the first time will automatically select all of the text ready to be copied by the user.
Panel:SelectAllText()
Selects all the text in a panel object. Will not select non-text items; for this, use Panel:SelectAll.
Panel:SelectNone()
Deselects all items in a panel object. For text-based objects, this will deselect all text.
Panel:SetAchievement( number id )
Sets the achievement to be displayed by AchievementIcon.
Panel:SetActionFunction( function func )
We advise against using this. It may be changed or removed in a future update. Does nothing at all. Used in Button to call a function when the button is clicked and in Slider when the value changes.
Panel:SetAllowNonAsciiCharacters( boolean allowed )
Configures a text input to allow user to type characters that are not included in the US-ASCII (7-bit ASCII) character set. Characters not included in US-ASCII are multi-byte characters in UTF-8. They can be accented characters, non-Latin characters and special characters.
Panel:SetAlpha( number alpha )
Sets the alpha multiplier for the panel
Panel:SetAnimationEnabled( boolean enable )
Enables or disables animations for the panel object by overriding the PANEL:AnimationThink hook to nil and back.
Panel:SetAutoDelete( boolean autoDelete )
Sets whenever the panel should be removed if the parent was removed.
Panel:SetBGColor( number r or color, number g, number b, number a )
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.
Panel:SetBGColorEx( number r, number g, number b, number a )
This is used internally - although you're able to use it you probably shouldn't. Sets the background color of the panel.
Panel:SetCaretPos( number offset )
Sets the position of the caret (or text cursor) in a text-based panel object.
Panel:SetCommand()
Sets the action signal command that's fired when a Button is clicked. The hook PANEL:ActionSignal is called as the click response. This has no effect on buttons unless it has had its AddActionSignalTarget method called (an internal function not available by default in Garry's Mod LUA). A better alternative is calling Panel:Command when a DButton is clicked.
Panel:SetContentAlignment( number alignment )
Sets the alignment of the contents.
Panel:SetConVar( string convar )
This function does not exist on all panelsThis function cannot interact with serverside convars unless you are hostBlocked convars will not work with this, see Blocked ConCommands Sets this panel's convar. When the convar changes this panel will update automatically. For developer implementation, see Derma_Install_Convar_Functions.
Panel:SetCookie( string cookieName, string value )
Stores a string in the named cookie using Panel:GetCookieName as prefix. You can also retrieve and modify this cookie by using the cookie. Cookies are stored in this format: panelCookieName.cookieNameThe panel's cookie name MUST be set for this function to work. See Panel:SetCookieName.
Panel:SetCookieName( string name )
Sets the panel's cookie name. Calls PANEL:LoadCookies if defined.
Panel:SetCursor( string cursor )
Sets the appearance of the cursor. You can find a list of all available cursors with image previews here.
Panel:SetDragParent( Panel parent )
Sets the drag parent. Drag parent means that when we start to drag this panel, we'll really start dragging the defined parent.
Panel:SetDrawLanguageID( boolean visible )
Sets the visibility of the language selection box in a TextEntry when typing in non-English mode. See Panel:SetDrawLanguageIDAtLeft for a function that changes the position of the language selection box.
Panel:SetDrawLanguageIDAtLeft( boolean left )
Sets where to draw the language selection box. See Panel:SetDrawLanguageID for a function that hides or shows the language selection box.
Panel:SetDrawOnTop( boolean drawOnTop = false )
Makes the panel render in front of all others, including the spawn menu and main menu. Priority is given based on the last call, so of two panels that call this method, the second will draw in front of the first. This only makes the panel draw above other panels. If there's another panel that would have otherwise covered it, users will not be able to interact with it.This does not work when using PANEL:SetPaintedManually or PANEL:PaintAt!
Panel:SetDropTarget( number x, number y, number width, number height )
Sets the target area for dropping when an object is being dragged around this panel using the dragndrop. This draws a target box of the specified size and position, until Panel:DragHoverEnd is called. It uses Panel:DrawDragHover to draw this area.
Panel:SetEnabled( boolean enable )
Sets the enabled state of a disable-able panel object, such as a DButton or DTextEntry. See Panel:IsEnabled for a function that retrieves the "enabled" state of a panel.
Panel:SetExpensiveShadow( number distance, table Color )
Adds a shadow falling to the bottom right corner of the panel's text. This has no effect on panels that do not derive from Label.
Panel:SetFGColor( number r or color, number g, number b, number a )
Sets the foreground color of a panel. For a Label or RichText, this is the color of its text. This function calls Panel:SetFGColorEx internally. This doesn't apply to all VGUI elements (such as DLabel) and its function varies between them
Panel:SetFGColorEx( number r, number g, number b, number a )
This is used internally - although you're able to use it you probably shouldn't. Sets the foreground color of the panel. For labels, this is the color of their text.
Panel:SetFocusTopLevel( boolean state )
Sets the panel that owns this FocusNavGroup to be the root in the focus traversal hierarchy. This function will only work on EditablePanel class panels and its derivatives.
Panel:SetFontInternal( string fontName )
Sets the font used to render this panel's text. To retrieve the font used by a panel, call Panel:GetFont.
Panel:SetHeight( number height )
Sets the height of the panel. Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout). See also Panel:SetSize.
Panel:SetHTML( string HTML code )
Allows you to set HTML code within a panel.
Panel:SetKeyboardInputEnabled( boolean enable )
Allows or disallows the panel to receive keyboard focus and input. This is recursively applied to all children.
Panel:SetKeyBoardInputEnabled( boolean keyboardInput )
We advise against using this. It may be changed or removed in a future update. Alias of Panel:SetKeyboardInputEnabled Enables or disables the keyboard input for the panel.
Panel:SetMaximumCharCount( number maxChar )
Sets the maximum character count this panel should have. This function will only work on RichText and TextEntry panels and their derivatives.
Panel:SetMinimumSize( number minW = nil, number minH = nil )
Sets the minimum dimensions of the panel or object. You can restrict either or both values. Calling the function without arguments will remove the minimum size.
Panel:SetModel( string ModelPath, number skin = 0, string bodygroups )
Sets the model to be displayed by SpawnIcon. This must be called after setting size if you wish to use a different size spawnicon
Panel:SetMouseInputEnabled( boolean mouseInput )
Enables or disables the mouse input for the panel.
Panel:SetName( string name )
Sets the internal name of the panel.
Panel:SetPaintBackgroundEnabled( boolean paintBackground )
Sets whenever all the default background of the panel should be drawn or not.
Panel:SetPaintBorderEnabled( boolean paintBorder )
Sets whenever all the default border of the panel should be drawn or not.
Panel:SetPaintedManually( boolean paintedManually )
Enables or disables painting of the panel manually with Panel:PaintManual.
Panel:SetPaintFunction()
We advise against using this. It may be changed or removed in a future update. This function does nothing. This function does nothing.
Panel:SetParent( Panel parent )
Sets the parent of the panel.
Panel:SetPlayer( Player player, number size )
Used by AvatarImage to load an avatar for given player.
Panel:SetPopupStayAtBack( boolean stayAtBack )
If this panel object has been made a popup with Panel:MakePopup, this method will prevent it from drawing in front of other panels when it receives input focus.
Panel:SetPos( number posX, number posY )
Sets the position of the panel's top left corner. This will trigger PANEL:PerformLayout. You should avoid calling this function in PANEL:PerformLayout to avoid infinite loops. If you wish to position and re-size panels without much guesswork and have them look good on different screen resolutions, you may find Panel:Dock useful
Panel:SetRenderInScreenshots( boolean renderInScreenshot )
Sets whenever the panel should be rendered in the next screenshot.
Panel:SetSelectable( boolean selectable )
Sets whether the panel object can be selected or not (like icons in the Spawn Menu, holding ⇧ shift). If enabled, this will affect the function of a DButton whilst ⇧ shift is pressed. Panel:SetSelected can be used to select/deselect the object.
Panel:SetSelected( boolean selected = false )
Sets the selected state of a selectable panel object. This functionality is set with Panel:SetSelectable and checked with Panel:IsSelectable.
Panel:SetSelectionCanvas( any selCanvas )
Enables the panel object for selection (much like the spawn menu).
Panel:SetSize( number width, number height )
Sets the size of the panel. Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout). See also Panel:SetWidth and Panel:SetHeight. If you wish to position and re-size panels without much guesswork and have them look good on different screen resolutions, you may find Panel:Dock useful
Panel:SetSkin( string skinName )
Sets the derma skin that the panel object will use, and refreshes all panels with derma.RefreshSkins.
Panel:SetSpawnIcon( string icon )
Sets the .png image to be displayed on a SpawnIcon or the panel it is based on ModelImage. Only .png images can be used with this function.
Panel:SetSteamID( string steamid, number size )
Used by AvatarImage panels to load an avatar by its 64-bit Steam ID (community ID).
Panel:SetTabPosition( number position )
When TAB is pressed, the next selectable panel in the number sequence is selected.
Panel:SetTall( number height )
Sets height of a panel. An alias of Panel:SetHeight.
Panel:SetTerm( number delay )
Removes the panel after given time in seconds. This function will not work if PANEL:AnimationThink is overridden, unless Panel:AnimationThinkInternal is called every frame.
Panel:SetText( string text )
Sets the text value of a panel object containing text, such as a Label, TextEntry or RichText and their derivatives, such as DLabel, DTextEntry or DButton. When used on a Label or its derivatives ( DLabel and DButton ), it will automatically call Panel:InvalidateLayout, meaning that you should avoid running this function every frame on these panels to avoid unnecessary performance loss.
Panel:SetTextInset( number insetX, number insetY )
Sets the left and top text margins of a text-based panel object, such as a DButton or DLabel.
Panel:SetToFullHeight()
Sets the height of a RichText element to accommodate the text inside. This function internally relies on Panel:GetNumLines, so it should be called at least a couple frames after modifying the text using Panel:AppendText
Panel:SetTooltip( string str )
Sets the tooltip to be displayed when a player hovers over the panel object with their cursor.
Panel:SetTooltipPanel( Panel tooltipPanel = nil )
Sets the panel to be displayed as contents of a DTooltip when a player hovers over the panel object with their cursor. See Panel:SetTooltipPanelOverride if you are looking to override DTooltip itself. Panel:SetTooltip will override this functionality.Calling this from PANEL:OnCursorEntered is too late! The tooltip will not be displayed or be updated.Given panel or the previously set one will NOT be automatically removed.
Panel:SetTooltipPanelOverride( string override )
Sets the panel class to be created instead of DTooltip when the player hovers over this panel and a tooltip needs creating.
Panel:SetUnderlineFont( string fontName )
Sets the underlined font for use by clickable text in a RichText. See also Panel:InsertClickableTextStart This function will only work on RichText panels.
Panel:SetURL( string url )
Sets the URL of a link-based panel such as DLabelURL.
Panel:SetVerticalScrollbarEnabled( boolean display = false )
Sets the visibility of the vertical scrollbar. Works for RichText and TextEntry.
Panel:SetVisible( boolean visible )
Sets the "visibility" of the panel.
Panel:SetWide( number width )
Sets width of a panel. An alias of Panel:SetWidth.
Panel:SetWidth( number width )
Sets the width of the panel. Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout). See also Panel:SetSize.
Panel:SetWorldClicker( boolean enabled )
This makes it so that when you're hovering over this panel you can click on the world. Your viewmodel will aim etc. This is primarily used for the Sandbox context menu. This function doesn't scale with custom FOV specified by GM:CalcView or WEAPON:TranslateFOV.Issue Tracker: 3467
Panel:SetWrap( boolean wrap )
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.
Panel:SetZPos( number zIndex )
Sets the panels z position which determines the rendering order. Panels with lower z positions appear behind panels with higher z positions. This also controls in which order panels docked with Panel:Dock appears.
Panel:Show()
Makes a panel visible.
Panel:SizeTo( number sizeW = 0, number sizeH = 0, number time, number delay = 0, number ease = -1, function callback )
Uses animation to resize the panel to the specified size.
Panel:SizeToChildren( boolean sizeW = false, boolean sizeH = false )
Resizes the panel to fit the bounds of its children. Your panel must have its layout updated (Panel:InvalidateLayout) for this function to work properly.The sizeW and sizeH parameters are false by default. Therefore, calling this function with no arguments will result in a no-op.
Panel:SizeToContents()
Resizes the panel so that its width and height fit all of the content inside. Only works on Label derived panels such as DLabel by default, and on any panel that manually implemented the Panel:SizeToContents method, such as DNumberWang and DImage.You must call this function AFTER setting text/font, adjusting child panels or otherwise altering the panel.
Panel:SizeToContentsX( number addVal = 0 )
Resizes the panel object's width to accommodate all child objects/contents. Only works on Label derived panels such as DLabel by default, and on any panel that manually implemented Panel:GetContentSize method. You must call this function AFTER setting text/font or adjusting child panels.
Panel:SizeToContentsY( number addVal = 0 )
Resizes the panel object's height to accommodate all child objects/contents. Only works on Label derived panels such as DLabel by default, and on any panel that manually implemented Panel:GetContentSize method. You must call this function AFTER setting text/font or adjusting child panels.
Panel:SlideDown( number Length )
Slides the panel in from above.
Panel:SlideUp( number Length )
Slides the panel out to the top.
Panel:StartBoxSelection()
Begins a box selection, enables mouse capture for the panel object, and sets the start point of the selection box to the mouse cursor's position, relative to this object. For this to work, either the object or its parent must be enabled as a selection canvas. This is set using Panel:SetSelectionCanvas.
Panel:Stop()
Stops all panel animations by clearing its animation list. This also clears all delayed animations.
Panel:StretchBottomTo( Panel tgtPanel, number offset = 0 )
Resizes the panel object's height so that its bottom is aligned with the top of the passed panel. An offset greater than zero will reduce the panel's height to leave a gap between it and the passed panel.
Panel:StretchRightTo( Panel tgtPanel, number offset = 0 )
Resizes the panel object's width so that its right edge is aligned with the left of the passed panel. An offset greater than zero will reduce the panel's width to leave a gap between it and the passed panel.
Panel:StretchToParent( number offsetLeft, number offsetTop, number offsetRight, number offsetBottom )
Sets the dimensions of the panel to fill its parent. It will only stretch in directions that aren't nil.
Panel:ToggleSelection()
Toggles the selected state of a selectable panel object. This functionality is set with Panel:SetSelectable and checked with Panel:IsSelectable. To check whether the object is selected or not, Panel:IsSelected is used.
Panel:ToggleVisible()
Toggles the visibility of a panel and all its children.
Panel:Undo()
Restores the last saved state (caret position and the text inside) of a TextEntry. Should act identically to pressing CTRL+Z in a TextEntry. See also Panel:SaveUndoState.
Panel:UnselectAll()
Recursively deselects this panel object and all of its children. This will cascade to all child objects at every level below the parent.
Panel:UpdateHTMLTexture()
Forcibly updates the panels' HTML Material, similar to when Paint is called on it.This is only useful if the panel is not normally visible, i.e the panel exists purely for its HTML Material. Only works on with panels that have a HTML Material. See Panel:GetHTMLMaterial for more details.A good place to call this is in the GM:PreRender hook
boolean Panel:Valid()
We advise against using this. It may be changed or removed in a future update. Use Panel:IsValid instead. Returns if a given panel is valid or not.

Methods

Panel Panel:Add( Panel object )
Adds the specified object to the panel.
Panel:AddText()
We advise against using this. It may be changed or removed in a future update. Does nothing This function does nothing.
Panel:AlignBottom( number offset = 0 )
Aligns the panel on the bottom of its parent with the specified offset.
Panel:AlignLeft( number offset = 0 )
Aligns the panel on the left of its parent with the specified offset.
Panel:AlignRight( number offset = 0 )
Aligns the panel on the right of its parent with the specified offset.
Panel:AlignTop( number offset = 0 )
Aligns the panel on the top of its parent with the specified offset.
Panel:AlphaTo( number alpha, number duration, number delay = 0, function callback )
Uses animation to transition the current alpha value of a panel to a new alpha, over a set period of time and after a specified delay.
Panel:AnimationThinkInternal()
This is used internally - although you're able to use it you probably shouldn't. Performs the per-frame operations required for panel animations. This is called every frame by PANEL:AnimationThink.
number Panel:AnimTail()
Returns the SysTime value when all animations for this panel object will end.
Panel:AppendText( string txt )
Appends text to a RichText element. This does not automatically add a new line.
Panel:ApplyGWEN( table GWENTable )
Used by Panel:LoadGWENFile and Panel:LoadGWENString to apply a GWEN controls table to a panel object. You can do this manually using file.Read and util.JSONToTable to import and create a GWEN table structure from a .gwen file. This method can then be called, passing the GWEN table's Controls member.
Panel:Center()
Centers the panel on its parent.
Panel:CenterHorizontal( number fraction = 0.5 )
Centers the panel horizontally with specified fraction.
Panel:CenterVertical( number fraction = 0.5 )
Centers the panel vertically with specified fraction.
number Panel:ChildCount()
Returns the amount of children of the of panel.
number, number Panel:ChildrenSize()
Returns the width and height of the space between the position of the panel (upper-left corner) and the max bound of the children panels (farthest reaching lower-right corner).
Panel:Clear()
Marks all of the panel's children for deletion.
Panel:ColorTo( table color, number length, number delay, function callback )
Fades panels color to specified one. It won't work unless panel has SetColor function.
Panel:Command( string command )
Sends an action command signal to the panel. The response is handled by PANEL:ActionSignal.
Panel:ConVarChanged( string newValue )
Updates a panel object's associated console variable. This must first be set up with Derma_Install_Convar_Functions, and have a ConVar set using Panel:SetConVar.
Panel:ConVarNumberThink()
A think hook for Panels using ConVars as a value. Call it in the Think hook. Sets the panel's value should the convar change. This function is best for: checkboxes, sliders, number wangs For a string alternative, see Panel:ConVarStringThink. Important: Make sure your Panel has a SetValue function, else you may get errors.
Panel:ConVarStringThink()
A think hook for panels using ConVars as a value. Call it in the Think hook. Sets the panel's value should the convar change. This function is best for: text inputs, read-only inputs, dropdown selects For a number alternative, see Panel:ConVarNumberThink. Important: Make sure your Panel has a SetValue function, else you may get errors.
Panel:CopyBase( Panel srcPanel )
Gets the size, position and dock state of the passed panel object, and applies it to this one.
Panel:CopyBounds( Panel base )
Copies position and size of the panel.
Panel:CopyHeight( Panel base )
Copies the height of the panel.
Panel:CopyPos( Panel base )
Copies the position of the panel.
Panel:CopySelected()
Performs the "CONTROL + C" key combination effect ( Copy selection to clipboard ) on selected text.
Panel:CopyWidth( Panel base )
Copies the width of the panel.
number, number Panel:CursorPos()
Returns the cursor position relative to the top left of the panel. This is equivalent to calling gui.MousePos and then Panel:ScreenToLocal. This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass. ie. inaccurate results may be returned if the panel or any of its ancestors have been repositioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.
Panel:CutSelected()
Performs the "CONTROL + X" ( delete text and copy it to clipboard buffer ) action on selected text.
Panel:DeleteCookie( string cookieName )
Deletes a cookie value using the panel's cookie name ( Panel:GetCookieName ) and the passed extension.
Panel:DisableLerp()
Resets the panel object's Panel:SetPos method and removes its animation table (Panel.LerpAnim). This effectively undoes the changes made by Panel:LerpPositions. In order to use Lerp animation again, you must call Panel:Stop before setting its SetPosReal property to 'nil'. See the example below.
number Panel:Distance( Panel tgtPanel )
Returns the linear distance from the center of this panel object and another. Both panels must have the same parent for this function to work properly.
number Panel:DistanceFrom( number posX, number posY )
Returns the distance between the center of this panel object and a specified point local to the parent panel.
Panel:Dock( number dockType )
Sets the dock type for the panel, making the panel "dock" in a certain direction, modifying it's position and size. You can set the inner spacing of a panel's docking using Panel:DockPadding, which will affect docked child panels, and you can set the outer spacing of a panel's docking using Panel:DockMargin, which affects how docked siblings are positioned/sized. After using this function, if you want to get the correct panel's bounds (position, size), use Panel:InvalidateParent (use true as arg..
Panel:DockMargin( number marginLeft, number marginTop, number marginRight, number marginBottom )
Sets the dock margin of the panel. The dock margin is the extra space that will be left around the edge when this element is docked inside its parent element.
Panel:DockPadding( number paddingLeft, number paddingTop, number paddingRight, number paddingBottom )
Sets the dock padding of the panel. The dock padding is the extra space that will be left around the edge when child elements are docked inside this element.
Panel:DoModal()
Makes the panel "lock" the screen until it is removed. All input will be directed to the given panel. It will silently fail if used while cursor is not visible. Call Panel:MakePopup before calling this function. This must be called on a panel derived from EditablePanel. You can still click in the world even if locked.Issue Tracker: 3457
boolean Panel:DragClick()
This is used internally - although you're able to use it you probably shouldn't. Called by Panel:DragMouseRelease when a user clicks one mouse button whilst dragging with another.
Panel:DragHover( number HoverTime )
This is used internally - although you're able to use it you probably shouldn't. Called by dragndrop.HoverThink to perform actions on an object that is dragged and hovered over another.
Panel:DragHoverEnd()
This is used internally - although you're able to use it you probably shouldn't. Called to end a drag and hover action. This resets the panel's PANEL:PaintOver method, and is primarily used by dragndrop.StopDragging.
Panel:DragMousePress( number mouseCode )
Called to inform the dragndrop that a mouse button is being held down on a panel object.
boolean Panel:DragMouseRelease( number mouseCode )
Called to inform the dragndrop that a mouse button has been depressed on a panel object.
Panel:DrawDragHover( number x, number y, number width, number height )
This is used internally - although you're able to use it you probably shouldn't. Called to draw the drop target when an object is being dragged across another. See Panel:SetDropTarget.
Panel:DrawFilledRect()
Draws a coloured rectangle to fill the panel object this method is called on. The colour is set using surface.SetDrawColor. This should only be called within the object's PANEL:Paint or PANEL:PaintOver hooks, as a shortcut for surface.DrawRect.
Panel:DrawOutlinedRect()
Draws a hollow rectangle the size of the panel object this method is called on, with a border width of 1 px. The border colour is set using surface.SetDrawColor. This should only be called within the object's PANEL:Paint or PANEL:PaintOver hooks, as a shortcut for surface.DrawOutlinedRect.
Panel:DrawSelections()
Used to draw the magenta highlight colour of a panel object when it is selected. This should be called in the object's PANEL:PaintOver hook. Once this is implemented, the highlight colour will be displayed only when the object is selectable and selected. This is achieved using Panel:SetSelectable and Panel:SetSelected respectively.
Panel:DrawTextEntryText( table textCol, table highlightCol, table cursorCol )
Used to draw the text in a DTextEntry within a derma skin. This should be called within the SKIN:PaintTextEntry skin hook. Will silently fail if any of arguments are not Color.
Panel:DrawTexturedRect()
Draws a textured rectangle to fill the panel object this method is called on. The texture is set using surface.SetTexture or surface.SetMaterial. This should only be called within the object's PANEL:Paint or PANEL:PaintOver hooks, as a shortcut for surface.DrawTexturedRect.
table Panel:Droppable( string name )
Makes this panel droppable. This is used with Panel:Receiver to create drag and drop events. Can be called multiple times with different names allowing to be dropped onto different receivers.
boolean Panel:EndBoxSelection()
Completes a box selection. If the end point of the selection box is within the selection canvas, mouse capture is disabled for the panel object, and the selected state of each child object within the selection box is toggled.
Panel:Exec( string cmd )
This is used internally - although you're able to use it you probably shouldn't. Used to run commands within a DHTML window.
Panel Panel:Find( string panelName )
Finds a panel in its children(and sub children) with the given name.
Panel:FocusNext()
Focuses the next panel in the focus queue.
Panel:FocusPrevious()
Focuses the previous panel in the focus queue.
number Panel:GetAlpha()
Returns the alpha multiplier for this panel.
number Panel:GetBGColor()
Returns 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
number, number, number, number Panel:GetBounds()
Returns the position and size of the panel. This is equivalent to calling Panel:GetPos and Panel:GetSize together.
number Panel:GetCaretPos()
Returns the position/offset of the caret (or text cursor) in a text-based panel object.
Panel:GetChild( number childIndex )
Gets a child by its index.
number, number Panel:GetChildPosition( Panel pnl )
Gets a child object's position relative to this panel object. The number of levels is not relevant; the child may have many parents between itself and the object on which the method is called.
table Panel:GetChildren()
Returns a table with all the child panels of the panel.
table Panel:GetChildrenInRect( number x, number y, number w, number h )
Returns a table of all visible, selectable children of the panel object that lie at least partially within the specified rectangle.
string Panel:GetClassName()
Returns the class name of the panel.
Panel, number Panel:GetClosestChild( number x, number y )
Returns the child of this panel object that is closest to the specified point. The point is relative to the object on which the method is called. The distance the child is from this point is also returned.
number, number Panel:GetContentSize()
Gets the size of the content/children within a panel object. Only works with Label derived panels by default such as DLabel. Will also work on any panel that manually implements this method.
string Panel:GetCookie( string cookieName, string default )
Gets the value of a cookie stored by the panel object. This can also be done with cookie.GetString, using the panel's cookie name, a fullstop, and then the actual name of the cookie. Make sure the panel's cookie name has not changed since writing, or the cookie will not be accessible. This can be done with Panel:GetCookieName and Panel:SetCookieName.
string Panel:GetCookieName()
Gets the name the panel uses to store cookies. This is set with Panel:SetCookieName.
number Panel:GetCookieNumber( string cookieName, number default )
Gets the value of a cookie stored by the panel object, as a number. This can also be done with cookie.GetNumber, using the panel's cookie name, a fullstop, and then the actual name of the cookie. Make sure the panel's cookie name has not changed since writing, or the cookie will not be accessible. This can be done with Panel:GetCookieName and Panel:SetCookieName.
number Panel:GetDock()
Returns a dock enum for the panel's current docking type.
number, number, number, number Panel:GetDockMargin()
Returns the docked margins of the panel. (set by Panel:DockMargin)
number, number, number, number Panel:GetDockPadding()
Returns the docked padding of the panel. (set by Panel:DockPadding)
table Panel:GetFGColor()
Returns the foreground color of the panel. For a Label or RichText, this is the color of its text. This doesn't apply to all VGUI elements (such as DLabel) and its function varies between them
string Panel:GetFont()
Returns the name of the font that the panel renders its text with. This is the same font name set with Panel:SetFontInternal.
IMaterial Panel:GetHTMLMaterial()
Returns the panel's HTML material. Only works with Awesomium, HTML and DHTML panels that have been fully loaded.
number Panel:GetMaximumCharCount()
Returns the current maximum character count. This function will only work on RichText and TextEntry panels and their derivatives.
string Panel:GetName()
Returns the internal name of the panel.
number Panel:GetNumLines()
Returns the number of lines in a RichText. You must wait a couple frames before calling this after using Panel:AppendText or Panel:SetText, otherwise it will return the number of text lines before the text change. Even though this function can be called on any panel, it will only work with RichText
Panel Panel:GetParent()
Returns the parent of the panel, returns nil if there is no parent.
number, number Panel:GetPos()
Returns the position of the panel relative to its Panel:GetParent. If you require the panel's position and size, consider using Panel:GetBounds instead. If you need the position in screen space, see Panel:LocalToScreen.
table Panel:GetSelectedChildren()
Returns a table of all children of the panel object that are selected. This is recursive, and the returned table will include tables for any child objects that also have children. This means that not all first-level members in the returned table will be of type Panel.
number, number Panel:GetSelectedTextRange()
Returns the currently selected range of text. This function will only work on RichText and TextEntry panels and their derivatives.
Panel Panel:GetSelectionCanvas()
Returns the panel object (self) if it has been enabled as a selection canvas. This is achieved using Panel:SetSelectionCanvas.
number, number Panel:GetSize()
Returns the size of the panel. If you require both the panel's position and size, consider using Panel:GetBounds instead.
table Panel:GetSkin()
Returns the table for the derma skin currently being used by this panel object.
table Panel:GetTable()
Returns the internal Lua table of the panel.
number Panel:GetTall()
Returns the height of the panel.
string Panel:GetText()
Returns the panel's text (where applicable). This method returns a maximum of 1023 bytes, except for DTextEntry.
number, number Panel:GetTextInset()
Gets the left and top text margins of a text-based panel object, such as a DButton or DLabel. This is set with Panel:SetTextInset.
number, number Panel:GetTextSize()
Gets the size of the text within a Label derived panel. This can return 0 incorrectly.Issue Tracker: 2576
Panel, table Panel:GetValidReceiverSlot()
Gets valid receiver slot of currently dragged panel.
any Panel:GetValue()
Returns the value the panel holds. In engine is only implemented for CheckButton, Label and TextEntry as a string. This function is limited to 8092 Bytes. If using DTextEntry, use Panel:GetText for unlimited bytes.
number Panel:GetWide()
Returns the width of the panel.
number Panel:GetZPos()
Returns the Z position of the panel.
Panel:GoBack()
Goes back one page in the HTML panel's history if available.
Panel:GoForward()
Goes forward one page in the HTML panel's history if available.
Panel:GoToHistoryOffset( number offset )
Goes to the page in the HTML panel's history at the specified relative offset.
Panel:GotoTextEnd()
Causes a RichText element to scroll to the bottom of its text.
Panel:GotoTextStart()
Causes a RichText element to scroll to the top of its text. This does not work on the same frame as Panel:SetText.Issue Tracker: 2239
Panel:GWEN_SetCheckboxText( string txt )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the CheckboxText property to a DCheckBoxLabel. This does exactly the same as Panel:GWEN_SetText, but exists to cater for the seperate GWEN properties.
Panel:GWEN_SetControlName( string name )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the ControlName property to a panel. This calls Panel:SetName.
Panel:GWEN_SetDock( string dockState )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Dock property to a panel object. This calls Panel:Dock.
Panel:GWEN_SetHorizontalAlign( string hAlign )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the HorizontalAlign property to a panel object. This calls Panel:SetContentAlignment.
Panel:GWEN_SetMargin( table margins )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Margin property to a panel object. This calls Panel:DockMargin.
Panel:GWEN_SetMax( number maxValue )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Max property to a DNumberWang, Slider, DNumSlider or DNumberScratch. This calls SetMax on one of the previously listed methods.
Panel:GWEN_SetMin( number minValue )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Min property to a DNumberWang, Slider, DNumSlider or DNumberScratch. This calls SetMin on one of the previously listed methods.
Panel:GWEN_SetPosition( table pos )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Position property to a panel object. This calls Panel:SetPos.
Panel:GWEN_SetSize( table size )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Size property to a panel object. This calls Panel:SetSize.
Panel:GWEN_SetText( string txt )
This is used internally - although you're able to use it you probably shouldn't. Used by Panel:ApplyGWEN to apply the Text property to a panel.
boolean Panel:HasChildren()
Returns whenever the panel has child panels.
boolean Panel:HasFocus()
Returns if the panel is focused.
boolean Panel:HasHierarchicalFocus()
Returns if the panel or any of its children(sub children and so on) has the focus.
boolean Panel:HasParent( Panel parentPanel )
Returns whether the panel is a descendent of the given panel.
Panel:Hide()
Makes a panel invisible.
Panel:InsertClickableTextEnd()
Marks the end of a clickable text segment in a RichText element, started with Panel:InsertClickableTextStart.
Panel:InsertClickableTextStart( string signalValue )
Starts the insertion of clickable text for a RichText element. Any text appended with Panel:AppendText between this call and Panel:InsertClickableTextEnd will become clickable text. The hook PANEL:ActionSignal is called when the text is clicked, with "TextClicked" as the signal name and signalValue as the signal value. The clickable text is a separate Derma panel which will not inherit the current font from the RichText.
Panel:InsertColorChange( number r, number g, number b, number a )
Inserts a color change in a RichText element, which affects the color of all text added with Panel:AppendText until another color change is applied.
Panel:InsertFade( number sustain, number length )
Begins a text fade for a RichText element where the last appended text segment is fully faded out after a specific amount of time, at a specific speed. The alpha of the text at any given time is determined by the text's base alpha * ((sustain - CurTime) / length) where CurTime is added to sustain when this method is called.
Panel:InvalidateChildren( boolean recursive = false )
Invalidates the layout of this panel object and all its children. This will cause these objects to re-layout immediately, calling PANEL:PerformLayout. If you want to perform the layout in the next frame, you will have loop manually through all children, and call Panel:InvalidateLayout on each.
Panel:InvalidateLayout( boolean layoutNow = false )
Causes the panel to re-layout in the next frame. During the layout process PANEL:PerformLayout will be called on the target panel. You should avoid calling this function every frame. Using this on a panel after clicking on a docked element will cause docked elements to reorient themselves incorrectly. This can be fixed by assigning a unique Panel:SetZPos to each docked element.Issue Tracker: 2574
Panel:InvalidateParent( boolean layoutNow = false )
Invalidates the layout of the parent of this panel object. This will cause it to re-layout, calling PANEL:PerformLayout.
boolean Panel:IsChildHovered( boolean immediate = false )
Determines whether the mouse cursor is hovered over one of this panel object's children. This is a reverse process using vgui.GetHoveredPanel, and looks upward to find the parent.
boolean Panel:IsDraggable()
Returns whether this panel is draggable ( if user is able to drag it ) or not.
boolean Panel:IsDragging()
Returns whether this panel is currently being dragged or not.
boolean Panel:IsEnabled()
Returns whether the the panel is enabled or disabled. See Panel:SetEnabled for a function that makes the panel enabled or disabled.
boolean Panel:IsHovered()
Returns whether the mouse cursor is hovering over this panel or not Uses vgui.GetHoveredPanel internally. Requires Panel:SetMouseInputEnabled to be set to true.
boolean Panel:IsKeyboardInputEnabled()
Returns true if the panel can receive keyboard input.
boolean Panel:IsLoading()
Determines whether or not a HTML or DHTML element is currently loading a page. Before calling Panel:SetHTML or DHTML:OpenURL, the result seems to be false with the Awesomium web renderer and true for the Chromium web renderer. This difference can be used to determine the available HTML5 capabilities.On Awesomium, the result remains true until the root document is loaded and when in-page content is loading (when adding pictures, frames, etc.). During this state, the HTML texture is not refreshed and the pa..
boolean Panel:IsMarkedForDeletion()
Returns if the panel is going to be deleted in the next frame.
boolean Panel:IsMouseInputEnabled()
Returns true if the panel can receive mouse input.
boolean Panel:IsOurChild( Panel childPanel )
Returns whether the panel contains the given panel, recursively.
boolean Panel:IsSelectable()
Determines if the panel object is selectable (like icons in the Spawn Menu, holding ⇧ shift). This is set with Panel:SetSelectable.
boolean Panel:IsSelected()
Returns if the panel object is selected (like icons in the Spawn Menu, holding ⇧ shift). This can be set in Lua using Panel:SetSelected.
any Panel:IsSelectionCanvas()
Determines if the panel object is a selection canvas or not. This is set with Panel:SetSelectionCanvas.
boolean Panel:IsValid()
Returns if the panel is valid and not marked for deletion.
boolean Panel:IsVisible()
Returns if the panel is visible.
boolean Panel:IsWorldClicker()
Returns if a panel allows world clicking set by Panel:SetWorldClicker.
Panel:KillFocus()
Remove the focus from the panel.
Panel:LerpPositions( number speed, boolean easeOut )
Redefines the panel object's Panel:SetPos method to operate using frame-by-frame linear interpolation (Lerp). When the panel's position is changed, it will move to the target position at the speed defined. You can undo this with Panel:DisableLerp. Unlike the other panel animation functions, such as Panel:MoveTo, this animation method will not operate whilst the game is paused. This is because it relies on FrameTime.
Panel:LoadControlsFromFile( string path )
We advise against using this. It may be changed or removed in a future update.This is used internally - although you're able to use it you probably shouldn't. Similar to Panel:LoadControlsFromString but loads controls from a file.
Panel:LoadControlsFromString( string data )
We advise against using this. It may be changed or removed in a future update.This is used internally - although you're able to use it you probably shouldn't. Loads controls(positions, etc) from given data. This is what the default options menu uses.
Panel:LoadGWENFile( string filename, string path = "GAME" )
Loads a .gwen file (created by GWEN Designer) and calls Panel:LoadGWENString with the contents of the loaded file. Used to load panel controls from a file.
Panel:LoadGWENString( string str )
Loads controls for the panel from a JSON string.
Panel:LoadTGAImage( string imageName, string strPath )
Sets a new image to be loaded by a TGAImage.
number, number Panel:LocalCursorPos()
Returns the cursor position local to the position of the panel (usually the upper-left corner).
number, number Panel:LocalToScreen( number posX, number posY )
Gets the absolute screen position of the position specified relative to the panel. See also Panel:ScreenToLocal. This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass, so inaccurate results may be returned if the panel or any of its ancestors have been re-positioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.If the panel uses Panel:Dock, this function will return 0, 0 when the panel was created. The position..
Panel:MakePopup()
Focuses the panel and enables it to receive input. This automatically calls Panel:SetMouseInputEnabled and Panel:SetKeyboardInputEnabled and sets them to true. Panels derived from Panel will not work properly with this function. Due to this, any children will not be intractable with keyboard. Derive from EditablePanel instead. For non gui related mouse focus, you can use gui.EnableScreenClicker.
Panel:MouseCapture( boolean doCapture )
Allows the panel to receive mouse input even if the mouse cursor is outside the bounds of the panel.
Panel:MoveAbove( Panel panel, number offset = 0 )
Places the panel above the passed panel with the specified offset.
Panel:MoveBelow( Panel panel, number offset = 0 )
Places the panel below the passed panel with the specified offset.
Panel:MoveBy( number moveX, number moveY, number time, number delay = 0, number ease = -1, function callback = nil )
Moves the panel by the specified coordinates using animation.
Panel:MoveLeftOf( Panel panel, number offset = 0 )
Places the panel left to the passed panel with the specified offset.
Panel:MoveRightOf( Panel panel, number offset = 0 )
Places the panel right to the passed panel with the specified offset.
Panel:MoveTo( number posX, number posY, number time, number delay = 0, number ease = -1, function callback )
Moves the panel to the specified position using animation. Setting the ease argument to 0 will result in the animation happening instantly, this applies to all MoveTo/SizeTo functions
boolean Panel:MoveToAfter( Panel siblingPanel )
Moves this panel object in front of the specified sibling (child of the same parent) in the render order, and shuffles up the Z-positions of siblings now behind.
Panel:MoveToBack()
Moves the panel object behind all other panels on screen. If the panel has been made a pop-up with Panel:MakePopup, it will still draw in front of any panels that haven't.
boolean Panel:MoveToBefore( Panel siblingPanel )
Moves this panel object behind the specified sibling (child of the same parent) in the render order, and shuffles up the Panel:SetZPos of siblings now in front.
Panel:MoveToFront()
Moves the panel in front of all other panels on screen. Unless the panel has been made a pop-up using Panel:MakePopup, it will still draw behind any that have.
table Panel:NewAnimation( number length, number delay = 0, number ease = -1, function callback = nil )
Creates a new animation for the panel object. Methods that use this function: Panel:MoveTo Panel:SizeTo Panel:SlideUp Panel:SlideDown Panel:ColorTo Panel:AlphaTo Panel:MoveBy Panel:LerpPositions
Panel:NewObject( string objectName )
This is used internally - although you're able to use it you probably shouldn't.
Panel:NewObjectCallback( string objectName, string callbackName )
This is used internally - although you're able to use it you probably shouldn't.
Panel:NoClipping( boolean clip )
Sets whether this panel's drawings should be clipped within the parent panel's bounds. See also DisableClipping.
number Panel:NumSelectedChildren()
Returns the number of children of the panel object that are selected. This is equivalent to calling Panel:IsSelected on all child objects and counting the number of returns that are true.
Panel:PaintAt( number posX, number posY )
Paints a ghost copy of the panel at the given position.
Panel:PaintManual()
Paints the panel at its current position. To use this you must call Panel:SetPaintedManually(true).
Panel:ParentToHUD()
Parents the panel to the HUD. Makes it invisible on the escape-menu and disables controls.
Panel:Paste()
Due to privacy concerns, this function has been disabled Only works for TextEntries. Pastes the contents of the clipboard into the TextEntry. Tab characters will be dropped from the pasted text
number Panel:PositionLabel( number lblWidth, number x, number y, Panel lbl, Panel panelObj )
Sets the width and position of a DLabel and places the passed panel object directly to the right of it. Returns the y value of the bottom of the tallest object. The panel on which this method is run is not relevant; only the passed objects are affected.
Panel:PostMessage( string messageName, string valueType, string value )
We advise against using this. It may be changed or removed in a future update. Only used in deprecated Derma controls. Sends a command to the panel.
Panel:Prepare()
This is used internally - although you're able to use it you probably shouldn't. Installs Lua defined functions into the panel.
Panel:Queue()
Enables the queue for panel animations. If enabled, the next new animation will begin after all current animations have ended. This must be called before Panel:NewAnimation to work, and only applies to the next new animation. If you want to queue many, you must call this before each.
Panel:RebuildSpawnIcon()
Causes a SpawnIcon to rebuild its model image.
Panel:RebuildSpawnIconEx( table data )
Re-renders a spawn icon with customized cam data. PositionSpawnIcon can be used to easily calculate the necessary camera parameters. This function does not accept the standard Structures/CamData.
Panel:Receiver( string name, function func, table menu )
Allows the panel to receive drag and drop events. Can be called multiple times with different names to receive multiple different draggable panel events.
Panel:Refresh( boolean ignoreCache = false )
Refreshes the HTML panel's current page.
Panel:Remove()
Marks a panel for deletion so it will be deleted on the next frame. This will not mark child panels for deletion this frame, but they will be marked and deleted in the next frame. See also Panel:IsMarkedForDeletion Will automatically call Panel:InvalidateParent.
Panel:RequestFocus()
Attempts to obtain focus for this panel.
Panel:ResetAllFades( boolean hold, boolean expiredOnly, number newSustain )
Resets all text fades in a RichText element made with Panel:InsertFade.
Panel:RunJavascript( string js )
Runs/Executes a string as JavaScript code in a panel. This function does NOT evaluate expression (i.e. allow you to pass variables from JavaScript (JS) to Lua context).Because a return value is nil/no value (a.k.a. void).If you wish to pass/return values from JS to Lua, you may want to use DHTML:AddFunction function to accomplish that job.The Awesomium web renderer automatically delays the code execution if the document is not ready, but the Chromium web renderer does not! This means that with Chromium, y..
Panel:SaveUndoState()
Saves the current state (caret position and the text inside) of a TextEntry as an undo state. See also Panel:Undo.
number, number Panel:ScreenToLocal( number screenX, number screenY )
Translates global screen coordinate to coordinates relative to the panel. See also Panel:LocalToScreen. This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass, so inaccurate results may be returned if the panel or any of its ancestors have been re-positioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.
Panel:SelectAll()
Selects all items within a panel or object. For text-based objects, selects all text.
Panel:SelectAllOnFocus()
If called on a text entry, clicking the text entry for the first time will automatically select all of the text ready to be copied by the user.
Panel:SelectAllText()
Selects all the text in a panel object. Will not select non-text items; for this, use Panel:SelectAll.
Panel:SelectNone()
Deselects all items in a panel object. For text-based objects, this will deselect all text.
Panel:SetAchievement( number id )
Sets the achievement to be displayed by AchievementIcon.
Panel:SetActionFunction( function func )
We advise against using this. It may be changed or removed in a future update. Does nothing at all. Used in Button to call a function when the button is clicked and in Slider when the value changes.
Panel:SetAllowNonAsciiCharacters( boolean allowed )
Configures a text input to allow user to type characters that are not included in the US-ASCII (7-bit ASCII) character set. Characters not included in US-ASCII are multi-byte characters in UTF-8. They can be accented characters, non-Latin characters and special characters.
Panel:SetAlpha( number alpha )
Sets the alpha multiplier for the panel
Panel:SetAnimationEnabled( boolean enable )
Enables or disables animations for the panel object by overriding the PANEL:AnimationThink hook to nil and back.
Panel:SetAutoDelete( boolean autoDelete )
Sets whenever the panel should be removed if the parent was removed.
Panel:SetBGColor( number r or color, number g, number b, number a )
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.
Panel:SetBGColorEx( number r, number g, number b, number a )
This is used internally - although you're able to use it you probably shouldn't. Sets the background color of the panel.
Panel:SetCaretPos( number offset )
Sets the position of the caret (or text cursor) in a text-based panel object.
Panel:SetCommand()
Sets the action signal command that's fired when a Button is clicked. The hook PANEL:ActionSignal is called as the click response. This has no effect on buttons unless it has had its AddActionSignalTarget method called (an internal function not available by default in Garry's Mod LUA). A better alternative is calling Panel:Command when a DButton is clicked.
Panel:SetContentAlignment( number alignment )
Sets the alignment of the contents.
Panel:SetConVar( string convar )
This function does not exist on all panelsThis function cannot interact with serverside convars unless you are hostBlocked convars will not work with this, see Blocked ConCommands Sets this panel's convar. When the convar changes this panel will update automatically. For developer implementation, see Derma_Install_Convar_Functions.
Panel:SetCookie( string cookieName, string value )
Stores a string in the named cookie using Panel:GetCookieName as prefix. You can also retrieve and modify this cookie by using the cookie. Cookies are stored in this format: panelCookieName.cookieNameThe panel's cookie name MUST be set for this function to work. See Panel:SetCookieName.
Panel:SetCookieName( string name )
Sets the panel's cookie name. Calls PANEL:LoadCookies if defined.
Panel:SetCursor( string cursor )
Sets the appearance of the cursor. You can find a list of all available cursors with image previews here.
Panel:SetDragParent( Panel parent )
Sets the drag parent. Drag parent means that when we start to drag this panel, we'll really start dragging the defined parent.
Panel:SetDrawLanguageID( boolean visible )
Sets the visibility of the language selection box in a TextEntry when typing in non-English mode. See Panel:SetDrawLanguageIDAtLeft for a function that changes the position of the language selection box.
Panel:SetDrawLanguageIDAtLeft( boolean left )
Sets where to draw the language selection box. See Panel:SetDrawLanguageID for a function that hides or shows the language selection box.
Panel:SetDrawOnTop( boolean drawOnTop = false )
Makes the panel render in front of all others, including the spawn menu and main menu. Priority is given based on the last call, so of two panels that call this method, the second will draw in front of the first. This only makes the panel draw above other panels. If there's another panel that would have otherwise covered it, users will not be able to interact with it.This does not work when using PANEL:SetPaintedManually or PANEL:PaintAt!
Panel:SetDropTarget( number x, number y, number width, number height )
Sets the target area for dropping when an object is being dragged around this panel using the dragndrop. This draws a target box of the specified size and position, until Panel:DragHoverEnd is called. It uses Panel:DrawDragHover to draw this area.
Panel:SetEnabled( boolean enable )
Sets the enabled state of a disable-able panel object, such as a DButton or DTextEntry. See Panel:IsEnabled for a function that retrieves the "enabled" state of a panel.
Panel:SetExpensiveShadow( number distance, table Color )
Adds a shadow falling to the bottom right corner of the panel's text. This has no effect on panels that do not derive from Label.
Panel:SetFGColor( number r or color, number g, number b, number a )
Sets the foreground color of a panel. For a Label or RichText, this is the color of its text. This function calls Panel:SetFGColorEx internally. This doesn't apply to all VGUI elements (such as DLabel) and its function varies between them
Panel:SetFGColorEx( number r, number g, number b, number a )
This is used internally - although you're able to use it you probably shouldn't. Sets the foreground color of the panel. For labels, this is the color of their text.
Panel:SetFocusTopLevel( boolean state )
Sets the panel that owns this FocusNavGroup to be the root in the focus traversal hierarchy. This function will only work on EditablePanel class panels and its derivatives.
Panel:SetFontInternal( string fontName )
Sets the font used to render this panel's text. To retrieve the font used by a panel, call Panel:GetFont.
Panel:SetHeight( number height )
Sets the height of the panel. Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout). See also Panel:SetSize.
Panel:SetHTML( string HTML code )
Allows you to set HTML code within a panel.
Panel:SetKeyboardInputEnabled( boolean enable )
Allows or disallows the panel to receive keyboard focus and input. This is recursively applied to all children.
Panel:SetKeyBoardInputEnabled( boolean keyboardInput )
We advise against using this. It may be changed or removed in a future update. Alias of Panel:SetKeyboardInputEnabled Enables or disables the keyboard input for the panel.
Panel:SetMaximumCharCount( number maxChar )
Sets the maximum character count this panel should have. This function will only work on RichText and TextEntry panels and their derivatives.
Panel:SetMinimumSize( number minW = nil, number minH = nil )
Sets the minimum dimensions of the panel or object. You can restrict either or both values. Calling the function without arguments will remove the minimum size.
Panel:SetModel( string ModelPath, number skin = 0, string bodygroups )
Sets the model to be displayed by SpawnIcon. This must be called after setting size if you wish to use a different size spawnicon
Panel:SetMouseInputEnabled( boolean mouseInput )
Enables or disables the mouse input for the panel.
Panel:SetName( string name )
Sets the internal name of the panel.
Panel:SetPaintBackgroundEnabled( boolean paintBackground )
Sets whenever all the default background of the panel should be drawn or not.
Panel:SetPaintBorderEnabled( boolean paintBorder )
Sets whenever all the default border of the panel should be drawn or not.
Panel:SetPaintedManually( boolean paintedManually )
Enables or disables painting of the panel manually with Panel:PaintManual.
Panel:SetPaintFunction()
We advise against using this. It may be changed or removed in a future update. This function does nothing. This function does nothing.
Panel:SetParent( Panel parent )
Sets the parent of the panel.
Panel:SetPlayer( Player player, number size )
Used by AvatarImage to load an avatar for given player.
Panel:SetPopupStayAtBack( boolean stayAtBack )
If this panel object has been made a popup with Panel:MakePopup, this method will prevent it from drawing in front of other panels when it receives input focus.
Panel:SetPos( number posX, number posY )
Sets the position of the panel's top left corner. This will trigger PANEL:PerformLayout. You should avoid calling this function in PANEL:PerformLayout to avoid infinite loops. If you wish to position and re-size panels without much guesswork and have them look good on different screen resolutions, you may find Panel:Dock useful
Panel:SetRenderInScreenshots( boolean renderInScreenshot )
Sets whenever the panel should be rendered in the next screenshot.
Panel:SetSelectable( boolean selectable )
Sets whether the panel object can be selected or not (like icons in the Spawn Menu, holding ⇧ shift). If enabled, this will affect the function of a DButton whilst ⇧ shift is pressed. Panel:SetSelected can be used to select/deselect the object.
Panel:SetSelected( boolean selected = false )
Sets the selected state of a selectable panel object. This functionality is set with Panel:SetSelectable and checked with Panel:IsSelectable.
Panel:SetSelectionCanvas( any selCanvas )
Enables the panel object for selection (much like the spawn menu).
Panel:SetSize( number width, number height )
Sets the size of the panel. Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout). See also Panel:SetWidth and Panel:SetHeight. If you wish to position and re-size panels without much guesswork and have them look good on different screen resolutions, you may find Panel:Dock useful
Panel:SetSkin( string skinName )
Sets the derma skin that the panel object will use, and refreshes all panels with derma.RefreshSkins.
Panel:SetSpawnIcon( string icon )
Sets the .png image to be displayed on a SpawnIcon or the panel it is based on ModelImage. Only .png images can be used with this function.
Panel:SetSteamID( string steamid, number size )
Used by AvatarImage panels to load an avatar by its 64-bit Steam ID (community ID).
Panel:SetTabPosition( number position )
When TAB is pressed, the next selectable panel in the number sequence is selected.
Panel:SetTall( number height )
Sets height of a panel. An alias of Panel:SetHeight.
Panel:SetTerm( number delay )
Removes the panel after given time in seconds. This function will not work if PANEL:AnimationThink is overridden, unless Panel:AnimationThinkInternal is called every frame.
Panel:SetText( string text )
Sets the text value of a panel object containing text, such as a Label, TextEntry or RichText and their derivatives, such as DLabel, DTextEntry or DButton. When used on a Label or its derivatives ( DLabel and DButton ), it will automatically call Panel:InvalidateLayout, meaning that you should avoid running this function every frame on these panels to avoid unnecessary performance loss.
Panel:SetTextInset( number insetX, number insetY )
Sets the left and top text margins of a text-based panel object, such as a DButton or DLabel.
Panel:SetToFullHeight()
Sets the height of a RichText element to accommodate the text inside. This function internally relies on Panel:GetNumLines, so it should be called at least a couple frames after modifying the text using Panel:AppendText
Panel:SetTooltip( string str )
Sets the tooltip to be displayed when a player hovers over the panel object with their cursor.
Panel:SetTooltipPanel( Panel tooltipPanel = nil )
Sets the panel to be displayed as contents of a DTooltip when a player hovers over the panel object with their cursor. See Panel:SetTooltipPanelOverride if you are looking to override DTooltip itself. Panel:SetTooltip will override this functionality.Calling this from PANEL:OnCursorEntered is too late! The tooltip will not be displayed or be updated.Given panel or the previously set one will NOT be automatically removed.
Panel:SetTooltipPanelOverride( string override )
Sets the panel class to be created instead of DTooltip when the player hovers over this panel and a tooltip needs creating.
Panel:SetUnderlineFont( string fontName )
Sets the underlined font for use by clickable text in a RichText. See also Panel:InsertClickableTextStart This function will only work on RichText panels.
Panel:SetURL( string url )
Sets the URL of a link-based panel such as DLabelURL.
Panel:SetVerticalScrollbarEnabled( boolean display = false )
Sets the visibility of the vertical scrollbar. Works for RichText and TextEntry.
Panel:SetVisible( boolean visible )
Sets the "visibility" of the panel.
Panel:SetWide( number width )
Sets width of a panel. An alias of Panel:SetWidth.
Panel:SetWidth( number width )
Sets the width of the panel. Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout). See also Panel:SetSize.
Panel:SetWorldClicker( boolean enabled )
This makes it so that when you're hovering over this panel you can click on the world. Your viewmodel will aim etc. This is primarily used for the Sandbox context menu. This function doesn't scale with custom FOV specified by GM:CalcView or WEAPON:TranslateFOV.Issue Tracker: 3467
Panel:SetWrap( boolean wrap )
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.
Panel:SetZPos( number zIndex )
Sets the panels z position which determines the rendering order. Panels with lower z positions appear behind panels with higher z positions. This also controls in which order panels docked with Panel:Dock appears.
Panel:Show()
Makes a panel visible.
Panel:SizeTo( number sizeW = 0, number sizeH = 0, number time, number delay = 0, number ease = -1, function callback )
Uses animation to resize the panel to the specified size.
Panel:SizeToChildren( boolean sizeW = false, boolean sizeH = false )
Resizes the panel to fit the bounds of its children. Your panel must have its layout updated (Panel:InvalidateLayout) for this function to work properly.The sizeW and sizeH parameters are false by default. Therefore, calling this function with no arguments will result in a no-op.
Panel:SizeToContents()
Resizes the panel so that its width and height fit all of the content inside. Only works on Label derived panels such as DLabel by default, and on any panel that manually implemented the Panel:SizeToContents method, such as DNumberWang and DImage.You must call this function AFTER setting text/font, adjusting child panels or otherwise altering the panel.
Panel:SizeToContentsX( number addVal = 0 )
Resizes the panel object's width to accommodate all child objects/contents. Only works on Label derived panels such as DLabel by default, and on any panel that manually implemented Panel:GetContentSize method. You must call this function AFTER setting text/font or adjusting child panels.
Panel:SizeToContentsY( number addVal = 0 )
Resizes the panel object's height to accommodate all child objects/contents. Only works on Label derived panels such as DLabel by default, and on any panel that manually implemented Panel:GetContentSize method. You must call this function AFTER setting text/font or adjusting child panels.
Panel:SlideDown( number Length )
Slides the panel in from above.
Panel:SlideUp( number Length )
Slides the panel out to the top.
Panel:StartBoxSelection()
Begins a box selection, enables mouse capture for the panel object, and sets the start point of the selection box to the mouse cursor's position, relative to this object. For this to work, either the object or its parent must be enabled as a selection canvas. This is set using Panel:SetSelectionCanvas.
Panel:Stop()
Stops all panel animations by clearing its animation list. This also clears all delayed animations.
Panel:StretchBottomTo( Panel tgtPanel, number offset = 0 )
Resizes the panel object's height so that its bottom is aligned with the top of the passed panel. An offset greater than zero will reduce the panel's height to leave a gap between it and the passed panel.
Panel:StretchRightTo( Panel tgtPanel, number offset = 0 )
Resizes the panel object's width so that its right edge is aligned with the left of the passed panel. An offset greater than zero will reduce the panel's width to leave a gap between it and the passed panel.
Panel:StretchToParent( number offsetLeft, number offsetTop, number offsetRight, number offsetBottom )
Sets the dimensions of the panel to fill its parent. It will only stretch in directions that aren't nil.
Panel:ToggleSelection()
Toggles the selected state of a selectable panel object. This functionality is set with Panel:SetSelectable and checked with Panel:IsSelectable. To check whether the object is selected or not, Panel:IsSelected is used.
Panel:ToggleVisible()
Toggles the visibility of a panel and all its children.
Panel:Undo()
Restores the last saved state (caret position and the text inside) of a TextEntry. Should act identically to pressing CTRL+Z in a TextEntry. See also Panel:SaveUndoState.
Panel:UnselectAll()
Recursively deselects this panel object and all of its children. This will cascade to all child objects at every level below the parent.
Panel:UpdateHTMLTexture()
Forcibly updates the panels' HTML Material, similar to when Paint is called on it.This is only useful if the panel is not normally visible, i.e the panel exists purely for its HTML Material. Only works on with panels that have a HTML Material. See Panel:GetHTMLMaterial for more details.A good place to call this is in the GM:PreRender hook
boolean Panel:Valid()
We advise against using this. It may be changed or removed in a future update. Use Panel:IsValid instead. Returns if a given panel is valid or not.