Garry's Mod Wiki

Revision Difference

Panel:SetTooltipPanel#550919

<function name="SetTooltipPanel" parent="Panel" type="classfunc"> <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</realm>⤶ <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 = panel:Add( "DButton" ) button2:Dock( TOP ) -- button2:SetTooltip( "test" ) -- This will stop SetTooltipPanel from working. button2:SetTooltipPanel( panel ) </code> </example>