Garry's Mod Wiki

Garry's Mod Wiki

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

Called every frame unless Panel:IsVisible is set to false. 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.
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.
PANEL:DroppedOn( Panel pnl )
Called when this panel is dropped onto another panel. Only works for panels derived from DDragBase.
PANEL:GenerateExample( string class, Panel dpropertysheet, number width, number height )
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.
Called whenever the cursor entered the panels bounds.
Called whenever the cursor left the panels bounds.
boolean PANEL:OnCursorMoved( number cursorX, number cursorY )
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.
Panel PANEL:OnDrop()
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.
PANEL:OnHScroll( number offset )
Called when the panel a child DHScrollBar is scrolled.
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
boolean PANEL:OnMousePressed( number keyCode )
Called whenever a mouse key was pressed while the panel is focused.
boolean PANEL:OnMouseReleased( number keyCode )
Called whenever a mouse key was released while the panel is focused.
boolean PANEL:OnMouseWheeled( number scrollDelta )
Called whenever the mouse wheel was used.
PANEL:OnRemove()
Called when the panel is about to be removed.
PANEL:OnScreenSizeChanged( number oldWidth, number oldHeight, number newWidth, number newHeight )
Called when the player's screen resolution of the game changes. ScrW and ScrH will return the new values when this hook is called.
Called when the panel a child DVScrollBar or DHScrollBar becomes visible.
PANEL:OnSizeChanged( number newWidth, number newHeight )
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!
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.
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.
PANEL:OnVScroll( number offset )
Called when the panel a child DVScrollBar is scrolled.
boolean PANEL:Paint( number width, number height )
Called whenever the panel should be drawn. You can create panels with a customized appearance by overriding their Paint() function, which will prevent the default appearance from being drawn. Render operations from the surface (and consequentially the draw) are always offset by the global position of this panel, as seen in the example belowThis hook will not run if the panel is completely off the screen. The hook will still run however if any parts of the panel are still on screen.
boolean PANEL:PaintOver( number width, number height )
Called whenever the panel and all its children were drawn, return true to override the default drawing.
PANEL:PerformLayout( number width, number height )
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.
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
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.

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...