diff --git a/garrysmod/lua/includes/extensions/client/panel.lua b/garrysmod/lua/includes/extensions/client/panel.lua index 0f80653043..ce72da53c2 100644 --- a/garrysmod/lua/includes/extensions/client/panel.lua +++ b/garrysmod/lua/includes/extensions/client/panel.lua @@ -288,6 +288,13 @@ function meta:GetTooltipPanel() return self.pnlTooltipPanel end +--[[--------------------------------------------------------- + Name: GetTooltipDelay +-----------------------------------------------------------]] +function meta:GetTooltipDelay() + return self.numTooltipDelay +end + --[[--------------------------------------------------------- Name: SetTooltip -----------------------------------------------------------]] @@ -310,6 +317,13 @@ function meta:SetTooltipPanelOverride( panel ) self.pnlTooltipPanelOverride = panel end +--[[--------------------------------------------------------- + Name: SetTooltipDelay +-----------------------------------------------------------]] +function meta:SetTooltipDelay( delay ) + self.numTooltipDelay = delay +end + --[[--------------------------------------------------------- Name: SizeToContentsY (Only works on Labels) -----------------------------------------------------------]] diff --git a/garrysmod/lua/vgui/dtooltip.lua b/garrysmod/lua/vgui/dtooltip.lua index 5892a9b52c..77d073308d 100644 --- a/garrysmod/lua/vgui/dtooltip.lua +++ b/garrysmod/lua/vgui/dtooltip.lua @@ -1,6 +1,7 @@ -- -- The delay before a tooltip appears +-- Can be overridden with PANEL:SetTooltipDelay -- local tooltip_delay = CreateClientConVar( "tooltip_delay", "0.5", true, false ) @@ -98,15 +99,16 @@ end function PANEL:OpenForPanel( panel ) self.TargetPanel = panel + self.OpenDelay = isnumber( panel.numTooltipDelay ) and panel.numTooltipDelay or tooltip_delay:GetFloat() self:PositionTooltip() -- Use the parent panel's skin self:SetSkin( panel:GetSkin().Name ) - if ( tooltip_delay:GetFloat() > 0 ) then + if ( self.OpenDelay > 0 ) then self:SetVisible( false ) - timer.Simple( tooltip_delay:GetFloat(), function() + timer.Simple( self.OpenDelay, function() if ( !IsValid( self ) ) then return end if ( !IsValid( panel ) ) then return end