Thread Tools Display Modes
06-20-17, 06:20 AM   #1
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
LibQTip-1.0 help

I have rewritten FeedTillers from scratch, as it badly needed it for a few reasons. Sure, MoP is way behind us, but some people still use this addon.

Two features I am trying to add are:
  1. The ability to hide any of the Tillers with whom you are Best Friends on saved variable toggle
  2. Clicking a line in the display to send TomTom a waypoint arrow to the Tiller's farm if he/she isn't at Halfhill
I mostly have the code working, but some things elude me. I haven't figured out LibQTip-1.0's API well enough to allow moving the mouse down the frame from whatever LDB display the user has. Instead, when I try to move the mouse down, the whole tooltip display disappears. I'd also like to highlight the line like a faded bar.

Speaking of LibDataBroker-1.1, I have had bug reports that ElvUI and TukUI do not support FeedTillers, but I have zero clue why that might be the case.

Next, I can't be sure I am using TomTom's API correctly, as wading through its code hunting for API arguments is challenging.

Then I have noticed that on first load the tooltip doesn't populate the food items correctly, but I have a guess; I just haven't tested it, but if someone notices where I have erred, I will be appreciative. My guess is move line 116 to line 102.

Finally, assuming that the user is Best Friends with all the Tillers, I would like the help instructions at the bottom to remain, but those go away when toggling Hide_Exalted.

Is there anything else I have missed that fresh eyes can spot?
Lua Code:
  1. --[[
  2.     file errata
  3.     File Author:    @file-author@
  4.     File Revision:  @file-revision@
  5.     FIle Date:      @file-date-iso@
  6. ]]--
  7.  
  8. -- for Mikk's FindGlobals app -------------------------------------------------
  9. -- GLOBALS: FeedTillersDB
  10.  
  11. -- main definitions -----------------------------------------------------------
  12. local addon_name = ...
  13. local lqt = LibStub("LibQTip-1.0")
  14. local TOMTOM = _G.TomTom
  15. local player_name, player_realm = UnitFullName("player")
  16. local full_name = player_name .. " - " .. player_realm
  17.  
  18. -- localize addon -------------------------------------------------------------
  19. -- see [url]https://phanx.net/addons/tutorials/localize[/url]
  20. local L = setmetatable({}, {__index = function(t, k)
  21.     local v = tostring(k)
  22.     rawset(t, k, v)
  23.     return v
  24. end})
  25.  
  26. local LOCALE = GetLocale()
  27.  
  28. if LOCALE == "enUS" then
  29. L["Click a line to set a TomTom waypoint, if installed"] = "Click a line to set a TomTom waypoint, if installed"
  30. L["Click the plugin to sort by Tiller name or item name"] = "Click the plugin to sort by Tiller name or item name"
  31. L["Hold the <Control> key and click to hide Best Friend Tillers"] = "Hold the <Control> key and click to hide Best Friend Tillers"
  32. L["Hold the <Shift> key and click to hide already fed Tillers"] = "Hold the <Shift> key and click to hide already fed Tillers"
  33. elseif LOCALE == "esES" then
  34. --@localization(locale="esES", format="lua_additive_table")@
  35. elseif LOCALE == "esMX" then
  36. --@localization(locale="esMX", format="lua_additive_table")@
  37. elseif LOCALE == "itIT" then
  38. --@localization(locale="itIT", format="lua_additive_table")@
  39. elseif LOCALE == "ptBR" then
  40. --@localization(locale="ptBR", format="lua_additive_table")@
  41. elseif LOCALE == "frFR" then
  42. --@localization(locale="frFR", format="lua_additive_table")@
  43. elseif LOCALE == "deDE" then
  44. --@localization(locale="deDE", format="lua_additive_table")@
  45. elseif LOCALE == "ruRU" then
  46. --@localization(locale="ruRU", format="lua_additive_table")@
  47. elseif LOCALE == "zhCN" then
  48. --@localization(locale="zhCN", format="lua_additive_table")@
  49. elseif LOCALE == "zhTW" then
  50. --@localization(locale="zhTW", format="lua_additive_table")@
  51. elseif LOCALE == "koKR" then
  52. --@localization(locale="koKR", format="lua_additive_table")@
  53. end
  54.  
  55. -- variables ------------------------------------------------------------------
  56. local TILLERS
  57. local npcs = {
  58.     { factionID = 1273, itemID = 74643, questID = 30439, coords = "53.6, 52.6" }, -- Jogu the Drunk
  59.     { factionID = 1275, itemID = 74651, questID = 30386, coords = "31.5, 58.1" }, -- Ella
  60.     { factionID = 1276, itemID = 74649, questID = 30396, coords = "30.9, 53.1" }, -- Old Hillpaw
  61.     { factionID = 1277, itemID = 74647, questID = 30402, coords = "34.4, 46.8" }, -- Chee Chee
  62.     { factionID = 1278, itemID = 74645, questID = 30408, coords = "29.5, 30.6" }, -- Sho
  63.     { factionID = 1279, itemID = 74642, questID = 30414, coords = "44.6, 34.1" }, -- Haohan Mudclaw
  64.     { factionID = 1280, itemID = 74652, questID = 30433, coords = "45.1, 33.8" }, -- Tina Mudclaw
  65.     { factionID = 1281, itemID = 74644, questID = 30390, coords = "53.2, 51.8" }, -- Gina Mudclaw
  66.     { factionID = 1282, itemID = 74655, questID = 30427, coords = "41.7, 30.0" }, -- Fish Fellreed
  67.     { factionID = 1283, itemID = 74654, questID = 30421, coords = "48.3, 33.8" }, -- Farmer Fung
  68. }
  69.  
  70. -- sorting functions ----------------------------------------------------------
  71. local function SortByName(a, b)
  72.     return a.name < b.name
  73. end
  74. local function SortByItem(a, b)
  75.     return a.item < b.item
  76. end
  77.  
  78. -- handle current_line scripts ------------------------------------------------
  79. local function line_OnEnter(frame)
  80.     frame:SetHighlightTexture(1, 1, 1, 0.2)
  81. end
  82.  
  83. local function line_OnLeave(frame)
  84.     frame:SetHighlightTexture(1, 1, 1, 0)
  85. end
  86.  
  87. local function line_OnMouseUp(self, npc)
  88.     if TOMTOM then
  89.         local x, y = strsplit(", ", npc.coords)
  90.         TOMTOM:AddWaypoint(5805, 0, x, y)
  91.     end
  92. end
  93.  
  94. -- DataBroker -----------------------------------------------------------------
  95. local function dataObject_OnEnter(self)
  96.     -- give it something so it doesn't nil on start
  97.     if not TILLERS then
  98.         TILLERS = GetFactionInfoByID(1272) -- cache name of the faction group for localization
  99.         for i = 1, #npcs do
  100.             local npc = npcs[i]
  101.             npc.name = GetFactionInfoByID(npc.factionID)
  102.         end
  103.         sort(npcs, SortByName)
  104.     end
  105.  
  106.     -- populate tooltip
  107.     local tooltip = lqt:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
  108.     self.tooltip = tooltip
  109.     tooltip:AddHeader(TILLERS, ITEMS, COMPLETE) -- "ITEMS" and "COMPLETE" are global strings
  110.     local current_line
  111.     local hideComplete = FeedTillersDB[full_name].Hide_Complete -- for brevity
  112.     local hideExalted = FeedTillersDB[full_name].Hide_Exalted -- for brevity
  113.  
  114.     for i = 1, #npcs do
  115.         local npc = npcs[i]
  116.         npc.item = npc.item or GetItemInfo(npc.itemID)
  117.         local isNotBestFriend = select(9, GetFriendshipReputation(npc.factionID)) -- number or nil if at max rank
  118.         hideExalted = hideExalted and isNotBestFriend == nil -- for my sanity
  119.  
  120.         if not IsQuestFlaggedCompleted(npc.questID) and not hideExalted then
  121.             local count = GetItemCount(npc.itemID)
  122.             current_line = tooltip:AddLine(npc.name, npc.item, format("%d/%d", count, 5))
  123.             if count < 5 then
  124.                 tooltip:SetLineColor(current_line, 1, 0.1, 0.1, 0.3)
  125.             end
  126.         elseif not hideComplete and not hideExalted then
  127.             current_line = tooltip:AddLine(npc.name, npc.item, YES)
  128.             tooltip:SetLineColor(current_line, 0.1, 1, 0.1, 0.3)
  129.         end
  130.  
  131.         -- current_line scripts
  132.         tooltip:SetLineScript(current_line, "OnEnter", line_OnEnter, npc)
  133.         tooltip:SetLineScript(current_line, "OnLeave", line_OnLeave, npc)
  134.         tooltip:SetLineScript(current_line, "OnMouseUp", line_OnMouseUp, npc)
  135.     end
  136.  
  137.     if not current_line then
  138.         hideComplete, hideExalted = nil, nil
  139.         self:GetScript("OnLeave")(self)
  140.         return self:GetScript("OnEnter")(self)
  141.     end
  142.  
  143.     current_line = tooltip:AddLine(" ")
  144.     current_line = tooltip:AddLine(" ")
  145.     tooltip:SetCell(current_line, 1, NORMAL_FONT_COLOR_CODE .. L["Click the plugin to sort by Tiller name or item name"], "LEFT", 3)
  146.     current_line = tooltip:AddLine(" ")
  147.     tooltip:SetCell(current_line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Shift> key and click to hide already fed Tillers"], "LEFT", 3)
  148.     current_line = tooltip:AddLine(" ")
  149.     tooltip:SetCell(current_line, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Control> key and click to hide Best Friend Tillers"], "LEFT", 3)
  150.     current_line = tooltip:AddLine(" ")
  151.     tooltip:SetCell(current_line, 1, NORMAL_FONT_COLOR_CODE .. L["Click a line to set a TomTom waypoint, if installed"], "LEFT", 3)
  152.  
  153.     -- smart anchoring of tooltip to DataBroker frame
  154.     tooltip:SmartAnchorTo(self)
  155.     tooltip:SetAutoHideDelay(0.25, self)
  156.  
  157.     -- show the tooltip
  158.     tooltip:Show()
  159. end
  160.  
  161. local function dataObject_OnLeave(self)
  162.     if lqt:IsAcquired("FeedTillersTT") then
  163.         lqt:Release(self.tooltip)
  164.     end
  165.     self.tooltip = nil
  166. end
  167.  
  168. local function dataObject_OnClick(self)
  169.     if IsShiftKeyDown() then
  170.         FeedTillersDB[full_name].Hide_Complete = not FeedTillersDB[full_name].Hide_Complete
  171.     elseif IsControlKeyDown() then
  172.         FeedTillersDB[full_name].Hide_Exalted = not FeedTillersDB[full_name].Hide_Exalted
  173.     else
  174.         FeedTillersDB[full_name].Current_Sort = FeedTillersDB[full_name].Current_Sort == "NAME" and "ITEM" or "NAME"
  175.         sort(npcs, FeedTillersDB[full_name].Current_Sort == "NAME" and SortByName or SortByItem)
  176.     end
  177.  
  178.     -- refresh display
  179.     self:GetScript("OnLeave")(self)
  180.     self:GetScript("OnEnter")(self)
  181. end
  182.  
  183. local function CreateBroker()
  184.     LibStub("LibDataBroker-1.1"):NewDataObject(addon_name, {
  185.         type = "data source",
  186.         text = "Feed Tillers",
  187.         icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
  188.         OnClick = dataObject_OnClick,
  189.         OnEnter = dataObject_OnEnter,
  190.         OnLeave = dataObject_OnLeave
  191.     })
  192. end
  193.  
  194. -- handle events --------------------------------------------------------------
  195. local event_frame = CreateFrame("frame")
  196. event_frame:RegisterEvent("ADDON_LOADED")
  197. event_frame:SetScript("OnEvent", function(self, event, ...)
  198.     if event == "ADDON_LOADED" and ... == addon_name then
  199.         -- load or initialize saved variables
  200.         FeedTillersDB = FeedTillersDB or {}
  201.         FeedTillersDB[full_name] = FeedTillersDB[full_name] or {}
  202.         FeedTillersDB[full_name].Hide_Complete = FeedTillersDB[full_name].Hide_Complete or false
  203.         FeedTillersDB[full_name].Hide_Exalted = FeedTillersDB[full_name].Hide_Exalted or false     
  204.         FeedTillersDB[full_name].Current_Sort = FeedTillersDB[full_name].Current_Sort or "NAME"
  205.  
  206.         -- groovy data display
  207.         CreateBroker()
  208.     end
  209.     self:UnregisterEvent("ADDON_LOADED")
  210. end)
  Reply With Quote
06-22-17, 07:06 PM   #2
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
Hi,
To stop the tooltip closing, you will need to add to your dataObject_OnLeave(self) function.

Lua Code:
  1. local function dataObject_OnLeave(self)
  2.     if MouseIsOver(self.tooltip) then return end
  3.     if lqt:IsAcquired("FeedTillersTT") then
  4.         lqt:Release(self.tooltip)
  5.     end
  6.     self.tooltip = nil
  7. end

As for the problem with you hint text dissapearing, I think its because when you hide_exalted the block of code at line 137 runs and then redraws the tooltip before you've added the hints to the tooltip. I may be wrong. You might want to re-write your condition check.
  Reply With Quote
06-25-17, 02:23 PM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
Thank you, and sorry for the late reply. That definitely worked. Now I just have to get TomTom's waypoint to function, and I think I am in business.
  Reply With Quote
06-30-17, 12:54 PM   #4
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I gibbled something. Since ElkFactions has similar functionality, I tried copying that code, but now my entire plugin won't display in a Broker bar.

This probably has something to do with lines 147 - 164 but that's just a guess. Why would I get no display at all?
Lua Code:
  1. --[[
  2.     file errata
  3.     File Author:    @file-author@
  4.     File Revision:  @file-revision@
  5.     FIle Date:      @file-date-iso@
  6. ]]--
  7.  
  8. -- for Mikk's FindGlobals app -------------------------------------------------
  9. -- GLOBALS: FeedTillersDB
  10.  
  11. -- main definitions -----------------------------------------------------------
  12. local addon_name, addon = ...
  13. local lqt = LibStub("LibQTip-1.0")
  14. local TOMTOM = _G.TomTom
  15. local player_realm = GetRealmName()
  16. local full_name = UnitName("player") .. " - " .. player_realm
  17.  
  18. -- localize addon -------------------------------------------------------------
  19. -- see [url]https://phanx.net/addons/tutorials/localize[/url]
  20. local L = setmetatable({}, {__index = function(t, k)
  21.     local v = tostring(k)
  22.     rawset(t, k, v)
  23.     return v
  24. end})
  25.  
  26. local LOCALE = GetLocale()
  27.  
  28. if LOCALE == "enUS" then
  29. L["Click a line to set a TomTom waypoint, if installed"] = "Click a line to set a TomTom waypoint, if installed"
  30. L["Click the plugin to sort by Tiller name or item name"] = "Click the plugin to sort by Tiller name or item name"
  31. L["error, cannot find TomTom, no waypoint added."] = "error, cannot find TomTom, no waypoint added."
  32. L["error, items in tooltip not yet populated. Try again later"] = "error, items in tooltip not yet populated. Try again later"
  33. L["Hold the <Control> key and click to hide Best Friend Tillers"] = "Hold the <Control> key and click to hide Best Friend Tillers"
  34. L["Hold the <Shift> key and click to hide already fed Tillers"] = "Hold the <Shift> key and click to hide already fed Tillers"
  35. elseif LOCALE == "esES" then
  36. --@localization(locale="esES", format="lua_additive_table")@
  37. elseif LOCALE == "esMX" then
  38. --@localization(locale="esMX", format="lua_additive_table")@
  39. elseif LOCALE == "itIT" then
  40. --@localization(locale="itIT", format="lua_additive_table")@
  41. elseif LOCALE == "ptBR" then
  42. --@localization(locale="ptBR", format="lua_additive_table")@
  43. elseif LOCALE == "frFR" then
  44. --@localization(locale="frFR", format="lua_additive_table")@
  45. elseif LOCALE == "deDE" then
  46. --@localization(locale="deDE", format="lua_additive_table")@
  47. elseif LOCALE == "ruRU" then
  48. --@localization(locale="ruRU", format="lua_additive_table")@
  49. elseif LOCALE == "zhCN" then
  50. --@localization(locale="zhCN", format="lua_additive_table")@
  51. elseif LOCALE == "zhTW" then
  52. --@localization(locale="zhTW", format="lua_additive_table")@
  53. elseif LOCALE == "koKR" then
  54. --@localization(locale="koKR", format="lua_additive_table")@
  55. end
  56.  
  57. -- variables ------------------------------------------------------------------
  58. local TILLERS
  59. local npcs = {
  60.     { factionID = 1273, itemID = 74643, questID = 30439, coords = "53.6 52.6" }, -- Jogu the Drunk
  61.     { factionID = 1275, itemID = 74651, questID = 30386, coords = "31.5 58.1" }, -- Ella
  62.     { factionID = 1276, itemID = 74649, questID = 30396, coords = "30.9 53.1" }, -- Old Hillpaw
  63.     { factionID = 1277, itemID = 74647, questID = 30402, coords = "34.4 46.8" }, -- Chee Chee
  64.     { factionID = 1278, itemID = 74645, questID = 30408, coords = "29.5 30.6" }, -- Sho
  65.     { factionID = 1279, itemID = 74642, questID = 30414, coords = "44.6 34.1" }, -- Haohan Mudclaw
  66.     { factionID = 1280, itemID = 74652, questID = 30433, coords = "45.1 33.8" }, -- Tina Mudclaw
  67.     { factionID = 1281, itemID = 74644, questID = 30390, coords = "53.2 51.8" }, -- Gina Mudclaw
  68.     { factionID = 1282, itemID = 74655, questID = 30427, coords = "41.7 30.0" }, -- Fish Fellreed
  69.     { factionID = 1283, itemID = 74654, questID = 30421, coords = "48.3 33.8" }, -- Farmer Fung
  70. }
  71.  
  72. -- sorting functions ----------------------------------------------------------
  73. local function SortByName(a, b)
  74.     return a.name < b.name
  75. end
  76. local function SortByItem(a, b)
  77.     if not a.item or not b.item then
  78.         return print("|cFFFF0000Feed Tillers: |r" .. L["error, items in tooltip not yet populated. Try again later"])
  79.     end
  80.  
  81.     return a.item < b.item
  82. end
  83.  
  84. -- broker functions -----------------------------------------------------------
  85. local function dataObject_OnEnter(frame)
  86.     local tooltip = lqt:Acquire("FeedTillersTT")
  87.     tooltip:SmartAnchorTo(frame)
  88.     tooltip:EnableMouse(true)
  89.     addon:UpdateTooltip()
  90.     tooltip:Show()
  91. end
  92.  
  93. local function dataObject_OnLeave()
  94.     -- empty dummy
  95. end
  96.  
  97. local function dataObject_OnClick(frame, button)
  98.     if button == "LeftButton" and IsShiftKeyDown() then
  99.         FeedTillersDB[full_name].Hide_Complete = not FeedTillersDB[full_name].Hide_Complete
  100.     elseif button == "LeftButton" and IsControlKeyDown() then
  101.         FeedTillersDB[full_name].Hide_Exalted = not FeedTillersDB[full_name].Hide_Exalted
  102.     else
  103.         FeedTillersDB[full_name].Current_Sort = FeedTillersDB[full_name].Current_Sort == "NAME" and "ITEM" or "NAME"
  104.         sort(npcs, FeedTillersDB[full_name].Current_Sort == "NAME" and SortByName or SortByItem)
  105.     end
  106. end
  107.  
  108. -- the line script handler
  109. local function line_OnMouseUp(frame, npc)
  110.     if TOMTOM then
  111.         local x, y = strsplit(" ", npc.coords)
  112.         x, y = tonumber(x), tonumber(y)
  113.         local desc = GetFactionInfoByID(npc.factionID)
  114.         -- TomTom API: continent, mapID, x, y, description, persistant, minimap, world, callbacks, silent, crazyArrow
  115.         TOMTOM:AddZWaypoint(862, 807, x, y, desc, true, true, true, nil, nil, true) -- 862 is continent Pandaria, 807 is the mapID for Valley of the Four Winds
  116.     else
  117.         return print("|cFFFF0000Feed Tillers: |r" .. L["error, cannot find TomTom, no waypoint added."])
  118.     end
  119. end
  120.  
  121. function addon:UpdateTooltip()
  122.     if not lqt:IsAcquired("FeedTillersTT") then return end
  123.  
  124.     local tooltip = lqt:Acquire("FeedTillersTT", 3, "LEFT", "LEFT", "RIGHT")
  125.     tooltip:Clear()
  126.     local currLine, item_name, isBestFriend, isComplete
  127.     TILLERS = TILLERS or GetFactionInfoByID(1272) -- cache name of the faction group for localization
  128.  
  129.     currLine = tooltip:AddHeader(TILLERS, ITEMS, COMPLETE)
  130.     local hideComplete = FeedTillersDB[full_name].Hide_Complete -- for brevity
  131.     local hideExalted = FeedTillersDB[full_name].Hide_Exalted -- for brevity
  132.  
  133.     for i = 1, #npcs do
  134.         local npc = npcs[i]
  135.         npc.name = GetFactionInfoByID(npc.factionID)
  136.         npc.itemName = GetItemInfo(npc.itemID)
  137.  
  138.         -- cache items, try to load from saved variables
  139.         FeedTillersDB[npc.name] = FeedTillersDB[npc.name] or npc.name
  140.         FeedTillersDB[npc.name].itemName = FeedTillersDB[npc.name].itemName or npc.itemName
  141.         item_name = FeedTillersDB[npc.name].itemName
  142.  
  143.         isBestFriend = select(9, GetFriendshipReputation(npc.factionID)) -- number or nil if at max rank
  144.         isComplete = IsQuestFlaggedCompleted(npc.questID)
  145.  
  146.         -- populate columns
  147.         if hideExalted and isBestFriend == nil then
  148.             currLine = tooltip:AddLine() -- add nothing
  149.         elseif hideComplete and isComplete then
  150.             currLine = tooltip:AddLine() -- add nothing
  151.         else
  152.             if not isComplete then
  153.                 local count = GetItemCount(npc.itemID)
  154.                 currLine = tooltip:AddLine(npc.name, item_name or "", format("%d/%d", count, 5))
  155.                 if count < 5 then
  156.                     tooltip:SetLineColor(currLine, 1, 0.1, 0.1, 0.3)
  157.                 else
  158.                     currLine = tooltip:AddLine(npc.name, item_name or "", YES)
  159.                     tooltip:SetLineColor(currLine, 0.1, 1, 0.1, 0.3)
  160.                 end
  161.             end
  162.         end
  163.         tooltip:SetLineScript(currLine, "OnMouseUp", line_OnMouseUp, npc)
  164.     end
  165.  
  166.     currLine = tooltip:AddLine(" ")
  167.     currLine = tooltip:AddLine(" ")
  168.     currLine = tooltip:SetCell(currLine, 1, NORMAL_FONT_COLOR_CODE .. L["Click the plugin to sort by Tiller name or item name"], "LEFT", 3)
  169.     currLine = tooltip:AddLine(" ")
  170.     currLine = tooltip:SetCell(currLine, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Shift> key and click to hide already fed Tillers"], "LEFT", 3)
  171.     currLine = tooltip:AddLine(" ")
  172.     currLine = tooltip:SetCell(currLine, 1, NORMAL_FONT_COLOR_CODE .. L["Hold the <Control> key and click to hide Best Friend Tillers"], "LEFT", 3)
  173.     currLine = tooltip:AddLine(" ")
  174.     currLine = tooltip:SetCell(currLine, 1, NORMAL_FONT_COLOR_CODE .. L["Click a line to set a TomTom waypoint, if installed"], "LEFT", 3)
  175. end
  176.  
  177. local function CreateBroker()
  178.     LibStub("LibDataBroker-1.1"):NewDataObject(addon_name, {
  179.         type = "data source",
  180.         text = "Feed Tillers",
  181.         icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
  182.         OnClick = dataObject_OnClick,
  183.         OnEnter = dataObject_OnEnter,
  184.         OnLeave = dataObject_OnLeave
  185.     })
  186. end
  187.  
  188. -- event handler --------------------------------------------------------------
  189. function addon:ADDON_LOADED(self, event, ...)
  190.     if ... ~= addon_name then return end
  191.  
  192.     FeedTillersDB = FeedTillersDB or {}
  193.     FeedTillersDB[full_name] = FeedTillersDB[full_name] or {}
  194.     FeedTillersDB[full_name].Hide_Complete = FeedTillersDB[full_name].Hide_Complete or false
  195.     FeedTillersDB[full_name].Hide_Exalted = FeedTillersDB[full_name].Hide_Exalted or false
  196.     FeedTillersDB[full_name].Current_Sort = FeedTillersDB[full_name].Current_Sort or "NAME"
  197.  
  198.     TILLERS = TILLERS or GetFactionInfoByID(1272) -- cache name of the faction group for localization
  199.  
  200.     CreateBroker()
  201.     self.event_frame:UnregisterEvent("ADDON_LOADED")
  202. end
  203.  
  204. -- register events ------------------------------------------------------------
  205. addon.event_frame = CreateFrame("Frame")
  206. addon.event_frame:SetScript("OnEvent", function(self, event, ...)
  207.     addon[event](self, ...)
  208. end)
  209. addon.event_frame:RegisterEvent("ADDON_LOADED")
  Reply With Quote
07-10-17, 03:34 AM   #5
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
When you create the dataobj, the function actually returns a reference to the data object, which you weren't catching. Take the creation of the data object out of the Addon Loaded event and the function.

Change the block at 183 to something like below:

Lua Code:
  1. local dataobj = LibStub("LibDataBroker-1.1"):NewDataObject(addon_name, {
  2.         type = "data source",
  3.         text = "Feed Tillers",
  4.         icon = [[Interface/ICONS/Achievement_Profession_ChefHat]],
  5.         OnClick = dataObject_OnClick,
  6.         OnEnter = dataObject_OnEnter,
  7.         OnLeave = dataObject_OnLeave
  8.     })

And remove the CreateBroker() call at 207.
  Reply With Quote
08-18-17, 07:48 PM   #6
TimothyLuke
A Fallenroot Satyr
 
TimothyLuke's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 24
Originally Posted by Ekaterina View Post
Hi,
To stop the tooltip closing, you will need to add to your dataObject_OnLeave(self) function.

Lua Code:
  1. local function dataObject_OnLeave(self)
  2.     if MouseIsOver(self.tooltip) then return end
  3.     if lqt:IsAcquired("FeedTillersTT") then
  4.         lqt:Release(self.tooltip)
  5.     end
  6.     self.tooltip = nil
  7. end

As for the problem with you hint text dissapearing, I think its because when you hide_exalted the block of code at line 137 runs and then redraws the tooltip before you've added the hints to the tooltip. I may be wrong. You might want to re-write your condition check.
Forgive my ignorance but does the tooltip itself have an onleave event? I an able to interact with the tooltip but when the mouse leaves it it stays there until i mouse back onto the LDB point and leave it.
__________________
BattleNet: TimothyLuke#1860
WowLazyMacros/Curse/GitHub/WowInterface: TimothyLuke

Most Commonly Played Characters:
Huldrych@Dath'Remar
Draik@Nagrand
  Reply With Quote
08-19-17, 05:59 AM   #7
Ekaterina
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 65
Forgive my ignorance but does the tooltip itself have an onleave event? I an able to interact with the tooltip but when the mouse leaves it it stays there until i mouse back onto the LDB point and leave it.
Taking a look at the LibQTip-1.0 api here at WowAce, the tooltip doesn't appear to have an automatic OnLeave function. The way I understand it is that the tooltip is a (collection of) frame/s, so you could register a function to the tootip's OnLeave event, but the easier way to close it is provided by the API. :SetAutoHideDelay(delay, alternateFrame, releaseHandler)

EG:
Lua Code:
  1. -- Hide after 0.25 seconds outside of the tooltip or an LibDataBroker data object
  2. function LDB_DO:OnEnter(self)
  3.     tooltip = LibStub('LibQTip-1.0'):Acquire('MyFooBarTooltip', 5, "LEFT", "CENTER")
  4.     tooltip:SmartAnchorTo(self)
  5.     tooltip:SetAutoHideDelay(0.25, self)
  6.     DisplayTooltip() -- Tooltip population function
  7. end

The above code is from the LibQTip API reference.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » LibQTip-1.0 help

Thread Tools
Display Modes

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