Thread Tools Display Modes
09-19-16, 10:07 AM   #1
flaicher
A Cyclonian
 
flaicher's Avatar
Join Date: Jan 2007
Posts: 46
Adding a tooltip to databroker addon?

I've been using Artifact Power addon for a while and stripped it down to bare minimum.. It would be perfect for me if I just could figure out how to add a tooltip to show the addon's date.
As documentation for all the stuff I'm interested in addon lua is almost non-existant..

Could some give me a few tips how to get started? With adding the tooltip to this addon.
  Reply With Quote
09-19-16, 02:28 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Adding a tooltip to an LDB plugin is simple. Create an OnTooltipShow method to your plugin object. It has one parameter, which is the tooltip object. Search any plugin's Lua file for the OnTooltipShow method if you need an example.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-19-16, 07:21 PM   #3
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Many LDB-enabled AddOns use LibQTip-1.0 for their tooltips, which doesn't work with OnTooltipShow and use OnEnter and OnLeave instead.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
09-19-16, 08:55 PM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Oh yeah, I didn't think of that. I guess it would depend on what you (the OP) want to show in your tooltip and how you want it displayed.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
09-20-16, 10:07 AM   #5
flaicher
A Cyclonian
 
flaicher's Avatar
Join Date: Jan 2007
Posts: 46
I used OnEnter and OnLeave as those seemed a simpler way to implement the minimal tooltip.
For some reason OnTooltipShow liked to give me errors
Although I might change to OnTooltipShow as addons that have their tooltips made by LibQTip don't want to get beautified by BenikUI (or ElvUI, not sure which one does it).

Thanks Torhal and Seerah
  Reply With Quote
09-24-16, 02:40 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Keep in mind that while OnEnter/OnLeave/OnClick/etc receive a reference to the actual frame object being entered/left/clicked/etc. as their first argument, OnTooltipShow does not get that -- it only gets a reference to the tooltip object being used to show the tooltip.

These should produce identical results:

Code:
local myPlugin = LibStub("LibDataBroker-1.1"):NewDataObject("MyPlugin", {
    text = "Hello world",
    OnEnter = function(frame)
        GameTooltip:SetOwner(frame, "ANCHOR_BOTTOMLEFT")
        GameTooltip:SetText("Hello!")
        GameTooltip:AddLine("This is my tooltip.")
        GameTooltip:Show()
    end,
    OnLeave = function(frame)
        GameTooltip:Hide()
    end
})
Code:
local myPlugin = LibStub("LibDataBroker-1.1"):NewDataObject("MyPlugin", {
    text = "Hello world",
    OnTooltipShow = function(tooltip)
        tooltip:SetText("Hello!")
        tooltip:AddLine("This is my tooltip.")
        tooltip:Show()
    end
})
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Adding a tooltip to databroker addon?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off