View Single Post
03-19-20, 04:23 PM   #6
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
You are setting an OnLeave script for the tooltip which is triggered by the OnEnter script within the tooltip. You want to set an OnRelease handler instead:
Code:
local ADDON = ...

local tooltip

local LibQTip = LibStub('LibQTip-1.0')

local function Button_OnClick(rowline, name, button)
    print("Never arrives here")
end

local function LoadTooltip()
    local row,col = tooltip:AddHeader()
    tooltip:SetCell(row,1,ADDON,"LEFT",4)
    
    row,col = tooltip:AddLine("var1","var2","var3","var4")
    tooltip:SetLineScript(row, 'OnMouseDown', Button_OnClick, "var1")   
    tooltip:SetHighlightTexture(1,1,0,.2)
end

local function OnRelease(self)
    tooltip = nil 
    print("Release tooltip")
end

local dataobj = LibStub("LibDataBroker-1.1"):NewDataObject(ADDON, {
    type = "data source",
    icon = "Interface\\Addons\\"..ADDON.."\\icon.tga",
    text = "-",

    OnEnter = function(self)
        if tooltip then return end
        tooltip = LibQTip:Acquire(ADDON.."tip", 4, "LEFT", "LEFT", "LEFT","LEFT")
        tooltip:EnableMouse(true)
        tooltip:SmartAnchorTo(self)
        tooltip.OnRelease = OnRelease
        tooltip:SetAutoHideDelay(1, self)
        LoadTooltip()
        tooltip:Show()
    end,

    OnLeave = function(self, motion)
        print("Leaving/Hiding broker frame")
        if tooltip and not motion then
            tooltip:Release()
        end
    end
})
  Reply With Quote