Revision Difference
Panel:SetTooltipPanel#565397
<function name="SetTooltipPanel" parent="Panel" type="classfunc">
<file line="309-L312">lua/includes/extensions/client/panel.lua</file>
<description>
Sets the panel to be displayed as contents of a <page>DTooltip</page> when a player hovers over the panel object with their cursor. See <page>Panel:SetTooltipPanelOverride</page> if you are looking to override <page>DTooltip</page> itself.
<note><page>Panel:SetTooltip</page> will override this functionality.</note>
<warning>
Calling this from <page>PANEL:OnCursorEntered</page> is too late! The tooltip will not be displayed or be updated.
Given panel or the previously set one will **NOT** be automatically removed.
</warning>
</description>
<realm>Client and Menu</realm>
<args>
<arg name="tooltipPanel" type="Panel" default="nil">The panel to use as the tooltip.</arg>
</args>
</function>
<example>
<description>Example usage of this function</description>
<code>
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 )
concommand.Add( "test_tooltip_content", function( ply )
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 )⤶
end )⤶
</code>
<output>⤶
<upload src="70c/8de029f729bbc5e.png" size="58419" name="image.png" />⤶
</output>⤶
</example>