PANEL
This is a list of hooks that are available on all panels.
Specific panels can have their own hooks, they are listed on their category.
These hooks are called on your panel. They can't be hooked
Inherits methods from Panel.
Events
PANEL:AnimationThink()
Called every frame unless the panel is not visible (Panel:IsVisible). Similar to PANEL:Think, but can be disabled by Panel:SetAnimationEnabled as explained below.
If you are overriding this, you must call Panel:AnimationThinkInternal every frame, else animations will cease to work.
If you want to "disable" this hook with Panel:SetAnimationEnabled, you must call it after defining this hook. Once disabled, a custom hook will not be re-enabled by Panel:SetAnimationEnabled again - the hook will have to be re-defined.
PANEL:ApplySchemeSettings()
Called whenever the panel should apply its scheme (colors, fonts, style).
It is called a few frames after panel's creation once.
The engine will overwrite Panel:SetFGColor and Panel:SetBGColor (from the engine panel theme/scheme) for most panels just before this hook is called in Lua.
PANEL:DragHoverClick( number hoverTime )
Called when an object is dragged and hovered over this panel for 0. 1 seconds.
This is used by DPropertySheet and DTree, for example to open a tab or expand a node when an object is hovered over it.
Called when this panel is dropped onto another panel.
Only works for panels derived from DDragBase.
Called when the panel should generate example use case / example code to use for this panel. Used in the panel opened by derma_controls console command.
PANEL:Init()
Called when the panel is created. This is called for each base type that the panel has.
PANEL:LoadCookies()
Called after Panel:SetCookieName is called on this panel to apply the just loaded cookie values for this panel.
PANEL:OnActivate()
This is used internally - although you're able to use it you probably shouldn't.
Called when we are activated during level load. Used by the loading screen panel.
PANEL:OnChildAdded( Panel child )
Called whenever a child was parented to the panel.
This is called before the panel's metatable is set. Issue Tracker: 2759
PANEL:OnChildRemoved( Panel child )
Called whenever a child of the panel is about to removed.
PANEL:OnCursorEntered()
Called whenever the cursor entered the panels bounds.
PANEL:OnCursorExited()
Called whenever the cursor left the panels bounds.
Called whenever the cursor was moved with the panels bounds.
PANEL:OnDeactivate()
This is used internally - although you're able to use it you probably shouldn't.
Called when we are deactivated during level load. Used by the loading screen panel.
We're being dropped on something
We can create a new panel here and return it, so that instead of dropping us - it drops the new panel instead! We remain where we are!
Only works for panels derived from DDragBase.
PANEL:OnFocusChanged( boolean gained )
Called whenever the panel gained or lost focus.
Panel:HasFocus will only be updated on the next frame and will return the "old" value at the time this hook is run. Same goes for vgui. GetKeyboardFocus.
Called whenever a keyboard key was pressed while the panel is focused.
This is not run for ESC/"cancelselect" binding. Issue Tracker: 2886
Called whenever a keyboard key was released while the panel is focused.
This is not run for TILDE/"toggleconsole" binding. Issue Tracker: 2886
Called whenever a mouse key was pressed while the panel is focused.
Called whenever a mouse key was released while the panel is focused.
Called whenever the mouse wheel was used.
PANEL:OnRemove()
Called when the panel is about to be removed.
Called when the player's screen resolution of the game changes.
ScrW and ScrH will return the new values when this hook is called.
PANEL:OnScrollbarAppear()
Called when the panel a child DVScrollBar or DHScrollBar becomes visible.
Called just after the panel size changes.
All size functions will return the new values when this hook is called.
Changing the panel size in this hook will cause an infinite loop!
PANEL:OnStartDragging()
This is used internally - although you're able to use it you probably shouldn't.
Called by dragndrop. StartDragging when the panel starts being dragged.
PANEL:OnStopDragging()
This is used internally - although you're able to use it you probably shouldn't.
Called by Panel:DragMouseRelease when the panel object is released after being dragged.
PANEL:OnTextClicked( string id )
Called whenever clickable text is clicked within a RichText.
Called whenever the panel should be drawn.
This hook will not run if the panel is completely off the screen, and will still run if any parts of the panel are still on screen.
You can create panels with a customized appearance by overriding their Paint() function, which will prevent the default appearance from being drawn.
See also PANEL:PaintOver.
Render operations from the surface library (and consequentially the draw library) are always offset by the global position of this panel, as seen in the example below
Called whenever the panel and all its children were drawn, return true to override the default drawing.
This is useful to draw content over the panel without having to overwrite it's PANEL:Paint hook, for example as an indicator that a panel is selected in PropSelect
Called whenever the panels' layout needs to be performed again. This means all child panels must be re-positioned to fit the possibly new size of this panel.
This can be triggered in numerous ways:
Panel:InvalidateLayout was called this or previous frame (depending on the argument)
Panel:SetPos called more than once on the same panel (Issue)
A child element was added to this panel (TODO: Verify me)
The size of this panel has changed
You should not call this function directly. Use Panel:InvalidateLayout instead.
You can use vgui_visualizelayout 1 to visualize panel layouts as they happen for debugging purposes. Panels should not be doing this every frame.
PANEL:PostAutoRefresh()
Only works on elements defined with derma. DefineControl and only if the panel has AllowAutoRefresh set to true.
Called after derma. DefineControl is called with panel's class name.
See also PANEL:PreAutoRefresh
PANEL:PreAutoRefresh()
Only works on elements defined with derma. DefineControl and only if the panel has AllowAutoRefresh set to true.
Called when derma. DefineControl is called with this panel's class name before applying changes to this panel.
See also PANEL:PostAutoRefresh
Called to test if the panel is being hovered by the mouse. This will only be called if the panel's parent is being hovered.
PANEL:Think()
Called every frame while Panel:IsVisible is true.