Custom tooltip for a single element (e.g. a button) only?

Hi. I’m trying to create a custom tooltip style that can be used on selected elements only. For example, a button can access the function “SetTooltip()”. I’d like to add my own tooltip method and call it “SetCustomTooltip()” but keep the original function as well. Here is my approach:

Interesting lua files:
garrysmod/lua/vgui/**dtooltip.lua **:
Line 180: derma.DefineControl( “DTooltip”, “”, PANEL, “DLabel” )
Line 52: Tooltip = vgui.Create( “DTooltip” )

If I just duplicate **dtooltip.lua ** and override some functions then it affects all tooltips.

After duplicating it, I could rename the control to: derma.DefineControl( “CustomTooltip”, “”, PANEL, “DLabel” ) - but I don’t know where this control needs to be called - and how to implement a “SetCustomTooltip()” method.

Hopefully it’s not too much to ask how to solve this, or is it even possible?

To make the :SetCustomTooltip() method you’re going to want to find the “Panel” metatable and just do:

function PanelMeta:SetCustomTooltip()
code here

You can pretty much just copy your Garry’s function “SetTooltip”, you can find it in “lua\includes\extensions\client” and make sure it creates your tooltip instead of “DTooltip”.

Thank you this helped me alot. :slight_smile:

No problem, you should mark your thread as solved if you think that answer was sufficient though.