Garry's Mod Wiki

Panel:SetTooltip

  Panel:SetTooltip( string str = nil )

Description

Sets the tooltip to be displayed when a player hovers over the panel object with their cursor.

By default, DTooltip will be used. Panel:SetTooltipPanelOverride can be used to override the tooltip panel.

Arguments

1 string str = nil
The text to be displayed in the tooltip. Set nil to disable it.

Example

Give DButton a tooltip, that will be automatically shown when the player hovers over the button for a certain amount of time, decided by tooltip_delay ConVar.

concommand.Add( "test_tooltip", function( ply ) local frame = vgui.Create( "DFrame" ) frame:SetSize( 200, 200 ) frame:Center() frame:MakePopup() local btn = frame:Add( "DButton" ) btn:SetPos( 20, 40 ) btn:SetSize( 100, 64 ) btn:SetText( "Hover over me!" ) btn:SetTooltip( "I am the tooltip text!" ) end )
Output:
October03-1797-gmod.gif