Garry's Mod Wiki

Panel

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. See also Panel Hooks.

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" )

Fields

Set to true by the dragndrop system when the panel is being drawn for the drag'n'drop.

Methods

Panel Panel:Add( Panel object )
When provided with a string or table, this function will create a new vgui element with that name and set the parent to the panel that this method is called on. When provided with a panel it will use Panel:SetParent on the provided panel to set it to our source 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 = nil )
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.
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.
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.
Appends text to a RichText element (exactly like Panel:AppendText), while also parsing and adding valid URLs (Panel:InsertClickableTextStart). 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. This will center the panel using the current size of the panel so should be called AFTER setting or adjusting the size of the panel
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.
Returns the amount of children of the of panel.
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()
Removes all of the panel's children. Many panels also override this method to gracefully clear their contents without breaking themselves.
Panel:ColorTo( table color, number length, number delay = 0, function callback = nil )
Fades panels color to specified one. The panel must have GetColor and SetColor functions for ColorTo to work.
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.
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. Make sure your Panel has a SetValue function, else you may get errors.
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. 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 in a TextEntry or RichText based element.
Panel:CopyWidth( Panel base )
Copies the width of the panel.
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 in a TextEntry or RichText based element.
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. You may need to use Panel:SetZPos to ensure child panels (DTextEntry) stay in a specific order. After using this function, if you want to get the correct panel's bounds (position, size), use Panel:InvalidateParent (use true as argument if you need to update immediately)
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.
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.
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. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
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. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
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 is usually called within the SKIN:PaintTextEntry skin hook. Will silently fail if any of arguments are not given. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
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. This is a rendering function that requires a 2d rendering context. This means that it will only work in 2d Rendering Hooks.
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.
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.
Returns the alpha multiplier for this panel.
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
Returns the position and size of the panel. This is equivalent to calling Panel:GetPos and Panel:GetSize together.
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. For use with Panel:ChildCount.
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.
Returns a table with all the child panels of the panel.
Returns a table of all visible, selectable children of the panel object that lie at least partially within the specified rectangle.
Returns the class name of the panel. This would be the class name of the base engine-level panel, not Lua classname. The latter is stored usually in Panel:GetName.
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.
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.
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.
Returns the docked margins of the panel. (set by Panel:DockMargin)
Returns the docked padding of the panel. (set by Panel:DockPadding)
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. Only works on Label and TextEntry and their derived panels by default (such as DLabel and DTextEntry), and on any panel that manually implemented the Panel:GetFont method.
Returns the panel's HTML material. Only works with Awesomium, HTML and DHTML panels that have been fully loaded.
Returns the height of a single line of a RichText panel.
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. Can be set via Panel:SetName.
Returns the number of lines in a RichText or a TextEntry. 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.
Returns the parent of the panel, returns nil if there is no parent.
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. See also Panel:GetX and Panel:GetY.
Returns the vertical and horizontal start indexes of a TextEntry's visible text. This is useful when the panel is scrolled.
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.
Returns the currently selected range of text. This function will only work on RichText and TextEntry panels and their derivatives.
Returns the panel object (self) if it has been enabled as a selection canvas. This is achieved using Panel:SetSelectionCanvas.
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. See Panel:GetWide for the width of the panel. See also Panel:GetSize for a function that returns both.
string Panel:GetText()
Returns the panel's text (where applicable). This method returns a maximum of 1023 bytes, except for DTextEntry.
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.
Gets the size of the text within a Label derived panel.
Returns the tooltip text that was set with PANEL:SetTooltip.
Returns the tooltip delay (time between hovering over the panel, and the tooltip showing up) that was set with Panel:SetTooltipDelay, or nothing if it was not set. If the delay is not explicitly set by this function, it will fallback to the value of the tooltip_delay ConVar, which is 0. 5 by default.
Returns the tooltip panel that was set with PANEL:SetTooltipPanel.
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. See Panel:GetTall for the height of the panel. See also Panel:GetSize for a function that returns both.
number Panel:GetX()
Returns the X position of the panel relative to its Panel:GetParent. Uses Panel:GetPos internally.
number Panel:GetY()
Returns the Y position of the panel relative to its Panel:GetParent. Uses Panel:GetPos internally.
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 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.
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.
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.
Returns whenever the panel has child panels.
Returns if the panel is focused.
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.
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:OnTextClicked is called when the text is clicked. The clickable text is a separate Derma panel which will not inherit the current font from the RichText.
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 )
Calls Panel:InvalidateLayout on the panel's parent. This function will silently fail if the panel has no parent. This will cause the parent panel to re-layout, calling PANEL:PerformLayout. Internally sets LayingOutParent to true on this panel, and will silently fail if it is already set.
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.
Returns whether this panel is draggable ( if user is able to drag it ) or not.
Returns whether this panel is currently being dragged or not.
Returns whether the the panel is enabled or disabled. See Panel:SetEnabled for a function that makes the panel enabled or disabled.
Returns whether the mouse cursor is hovering over this panel or not Uses vgui. GetHoveredPanel internally. Requires Panel:SetMouseInputEnabled to be set to true.
Returns true if the panel can receive keyboard input.
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 panel is not painted (it becomes invisible). On Chromium, the value is only true when the root document is not ready. The rendering is not suspended when in-page elements are loading.
Returns if the panel is going to be deleted in the next frame.
Returns whether the panel was made modal or not. See Panel:DoModal.
Returns true if the panel can receive mouse input.
Determines whether or not a TextEntry panel is in multi-line mode. This is set with Panel:SetMultiline.
boolean Panel:IsOurChild( Panel childPanel )
Returns whether the panel contains the given panel, recursively.
Returns if the panel was made popup or not. See Panel:MakePopup
Determines if the panel object is selectable (like icons in the Spawn Menu, holding ⇧ shift). This is set with Panel:SetSelectable.
Returns if the panel object is selected (like icons in the Spawn Menu, holding ⇧ shift). This can be set in Lua using Panel:SetSelected.
Determines if the panel object is a selection canvas or not. This is set with Panel:SetSelectionCanvas.
Returns if the panel is valid and not marked for deletion.
Returns if the panel is visible. This will NOT take into account visibility of the parent.
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.
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.
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.
Returns the cursor position local to the position of the panel (usually the upper-left corner).
number, number Panel:LocalToScreen( number posX, number posY )
Takes X and Y coordinates relative to the panel and returns their corresponding positions relative to the screen. 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 will be updated in the next frame.
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 = nil )
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 noclip )
Sets whether this panel's drawings should be clipped within the parent panel's bounds. This only disabled clipping for the Paint Related functions (as far as i can tell at the current moment, more testing should be done) so things like the text of a DLabel will still be clipped to the parent. To fully disable the clipping of any children see DisableClipping.
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:OpenURL( string URL )
Instructs a HTML control to download and parse a HTML script using the passed URL. This function can only be used on HTML panel and its derivatives.
Panel:PaintAt( number posX, number posY )
Paints a ghost copy of the panel at the given position. This function sets Z pos of panel's children (PANEL:SetZPos)
Panel:PaintManual( boolean unclamp = false )
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()
We advise against using this. It may be changed or removed in a future update. 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: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.
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 CamData structure.
Panel:Receiver( string name, function func, table menu = nil )
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 )
Executes a string as JavaScript code on a web document panel. This function does NOT allow you to pass variables from JavaScript (JS) to Lua context. 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, you cannot JavaScript run code immediatly after calling Panel:SetHTML or Panel:OpenURL. You should wait for the events PANEL:OnDocumentReady or PANEL:OnFinishLoadingDocument to be triggered before proceeding, otherwise you may manipulate an empty / incomplete document.
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. Only works on RichText and TextEntry and their derived panels by default (such as DTextEntry), and on any panel that manually reimplemented this method.
If called on a TextEntry, clicking the text entry for the first time will automatically select all of the text ready to be copied by the user.
Panel:SelectAllText( boolean resetCursorPos )
We advise against using this. It may be changed or removed in a future update. Duplicate of Panel:SelectAll. 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. Only works on RichText and TextEntry and their derived panels by default (such as DTextEntry), and on any panel that manually reimplemented this method.
Panel:SetAchievement( number id )
Sets the achievement to be displayed by AchievementIcon.
Configures a TextEntry 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, DColorCube or the base Panel. For many panels, such as DLabel and Panel, you must use Panel:SetPaintBackgroundEnabled( true ) for the background to appear. Please note that for most panels the engine will overwrite the foreground and background colors a frame after panel creation via the PANEL:ApplySchemeSettings hook, so you may want to set the color in that hook instead. See Panel:SetFGColor for the foreground color. This doesn't apply to all VGUI elements and its function varies between them
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:SetContentAlignment( number alignment )
Sets the alignment of the contents. This function only works on Label panels and its derivatives.
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 when typing in non-English mode. See Panel:SetDrawLanguageIDAtLeft for a function that changes the position of the language selection box.
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. Completely disregards PANEL:ParentToHUD. 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 works only on panels that 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. Please note that for most panels the engine will overwrite the foreground and background colors a frame after panel creation via the PANEL:ApplySchemeSettings hook, so you may want to set the color in that hook instead. See Panel:SetBGColor for the background color. 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. This works for Label, TextEntry and RichText, but it's a better idea to use their local SetFont (DTextEntry:SetFont, DLabel:SetFont) methods when available. 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 )
Allows you to set HTML code within a panel.
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.
Sets the height of a single line of a RichText 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 = nil )
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. Panels parented to the context menu will not be clickable unless Panel:SetKeyboardInputEnabled is enabled or Panel:MakePopup has been called. If you want the panel to have mouse input but you do not want to prevent players from moving, set Panel:SetKeyboardInputEnabled to false immediately after calling Panel:MakePopup.
Panel:SetMultiline( boolean multiline )
Enables or disables the multi-line functionality of TextEntry panel and its derivatives.
Panel:SetName( string name )
Sets the internal name of the panel. Can be retrieved with Panel:GetName.
Panel:SetOpenLinksExternally( boolean openExternally )
Set to true to open links in an external browser. This only functions on the x86-64 beta.
Panel:SetPaintBackgroundEnabled( boolean paintBackground )
Sets whether the default background of the panel should be drawn or not. It's color is usually set by Panel:SetBGColor.
Panel:SetPaintBorderEnabled( boolean paintBorder )
Sets whether 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:SetParent( Panel parent )
Sets the parent of the panel. Panels parented to the context menu will not be clickable unless Panel:SetMouseInputEnabled and Panel:SetKeyboardInputEnabled are both true or Panel:MakePopup has been called. If you want the panel to have mouse input but you do not want to prevent players from moving, set Panel:SetKeyboardInputEnabled to false immediately after calling Panel:MakePopup.
Panel:SetPlayer( Player player, number size = 32 )
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. See also Panel:SetX and Panel:SetY. 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.
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:SetTextSelectionColors( table textColor, table backgroundColor )
Sets text selection colors of a RichText element.
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 = nil )
Sets the tooltip to be displayed when a player hovers over the panel object with their cursor.
Panel:SetTooltipDelay( number tooltip )
Sets the tooltip delay. (time between hovering over the panel, and the tooltip showing up) Can be retrieved with Panel:GetTooltipDelay.
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 enable )
This makes it so that when you're hovering over this panel you can "click" on the world. Your weapon aim (and its viewmodel) will follow the cursor. This is primarily used for the Sandbox context menu.
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:SetX( number x )
Sets the X position of the panel. Uses Panel:SetPos internally.
Panel:SetY( number y )
Sets the Y position of the panel. Uses Panel:SetPos internally.
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 = nil )
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.
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.
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:StopLoading()
Stops the loading of the HTML panel's current page.
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 = nil, number offsetTop = nil, number offsetRight = nil, number offsetBottom = nil )
Sets the dimensions of the panel to fill its parent. It will only stretch in directions that aren't nil.
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.
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.