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:
Fields
boolean Panel.PaintingDragging
Set to true by the dragndrop system when the panel is being drawn for the drag'n'drop.
Methods
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.
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.
Aligns the panel on the top of its parent with the specified offset.
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.
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:AppendTextWithURLs( string txt )
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.
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.
number Panel:ChildCount()
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.
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.
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.
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.
Make sure your Panel has a SetValue function, else you may get errors.
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:CopySelected()
Performs the control + c key combination effect ( Copy selection to clipboard ) on selected text in a TextEntry or RichText based element.
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.
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.
Returns the distance between the center of this panel object and a specified point local to the parent panel.
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)
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.
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.
Called to inform the dragndrop that a mouse button has been depressed on a panel object.
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.
This is a rendering function that requires a 2d rendering context.
This means that it will only work in 2d Rendering Hooks.
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.
This is a rendering function that requires a 2d rendering context.
This means that it will only work in 2d Rendering Hooks.
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.
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.
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.
This is a rendering function that requires a 2d rendering context.
This means that it will only work in 2d Rendering Hooks.
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.
This is used internally - although you're able to use it you probably shouldn't.
Used to run commands within a DHTML window.
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: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
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.
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.
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. 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.
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.
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.
Returns the docked margins of the panel. (set by Panel:DockMargin)
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
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.
IMaterial Panel:GetHTMLMaterial()
Returns the panel's HTML material. Only works with Awesomium, HTML and DHTML panels that have been fully loaded.
number Panel:GetLineHeight()
Returns the height of a single line of a RichText panel.
number Panel:GetMaximumCharCount()
Returns the current maximum character count.
This function will only work on RichText and TextEntry panels and their derivatives.
number Panel:GetNumLines()
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 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.
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.
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.
Returns the size of the panel.
If you require both the panel's position and size, consider using Panel:GetBounds instead.
Returns the table for the derma skin currently being used by this panel object.
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.
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.
string Panel:GetTooltip()
Returns the tooltip text that was set with PANEL:SetTooltip.
number Panel:GetTooltipDelay()
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.
Panel Panel:GetTooltipPanel()
Returns the tooltip panel that was set with PANEL:SetTooltipPanel.
Gets valid receiver slot of currently dragged panel.
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.
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.
Returns the X position of the panel relative to its Panel:GetParent.
Uses Panel:GetPos internally.
Returns the Y position of the panel relative to its Panel:GetParent.
Uses Panel:GetPos internally.
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.
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:HasHierarchicalFocus()
Returns if the panel or any of its children(sub children and so on) has the focus.
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: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.
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.
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.
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.
boolean Panel:IsKeyboardInputEnabled()
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.
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:IsMultiline()
Determines whether or not a TextEntry panel is in multi-line mode. This is set with Panel:SetMultiline.
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.
Returns if the panel is visible. This will NOT take into account visibility of the parent.
boolean Panel:IsWorldClicker()
Returns if a panel allows world clicking set by Panel:SetWorldClicker.
Panel:KillFocus()
Remove the focus from the panel.
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.
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.
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).
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.
Places the panel above the passed panel with the specified offset.
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.
Places the panel left to the passed panel with the specified offset.
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
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.
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
This is used internally - although you're able to use it you probably shouldn't.
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.
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.
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.
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.
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
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.
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 CamData structure.
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: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.
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.
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.
Panel:SelectAllOnFocus()
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.
Panel:SetAllowNonAsciiCharacters( boolean allowed )
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: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.
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
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.
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.
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.
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.
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.
Completely disregards PANEL:ParentToHUD. This does not work when using PANEL:SetPaintedManually or PANEL:PaintAt.
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.
Adds a shadow falling to the bottom right corner of the panel's text.
This works only on panels that derive from Label.
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
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.
Sets the height of the panel.
Calls PANEL:OnSizeChanged and marks this panel for layout (Panel:InvalidateLayout).
See also Panel:SetSize.
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.
number Panel:SetLineHeight()
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.
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.
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.
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.
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.
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.
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.
Panel:SetSelectionCanvas( boolean set )
Enables the panel object for selection (much like the spawn menu).
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
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.
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.
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.
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.
Sets the left and top text margins of a text-based panel object, such as a DButton or DLabel.
Sets text selection colors of a RichText element.
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 = 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: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.
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.
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.
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.
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: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:StopLoading()
Stops the loading of the HTML panel's current page.
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.
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.
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