Garry's Mod Wiki

Panel:SetTooltipPanel

  Panel:SetTooltipPanel( Panel tooltipPanel = nil )

Description

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.

Arguments

1 Panel tooltipPanel = nil
The panel to use as the tooltip.

Example

Example usage of this function

local frame = vgui.Create( "DFrame" ) frame:SetSize( 500, 500 ) frame:Center() frame:MakePopup() local panel = vgui.Create( "Panel" ) panel:SetSize( 100, 100 ) panel:SetVisible( false ) panel.Paint = function( self, width, height ) surface.SetDrawColor( 255, 0, 0 ) surface.DrawRect( 0, 0, width, height) end local button1 = vgui.Create( "DButton", panel ) button1:SetText( "test" ) button1:SetSize( 50, 50 ) button1:SetPos( 5, 5 ) local button2 = frame:Add( "DButton" ) button2:Dock( TOP ) -- button2:SetTooltip( "test" ) -- This will stop SetTooltipPanel from working. button2:SetTooltipPanel( panel )