Getting Started

Usage

Get a reference to the library:
local QTC = LibStub('LibQTipClick-1.0')
Mostly, usage is exactly as in LibQTip.

Supported cell functions

  • OnEnter
  • OnLeave
  • OnMouseDown
These functions are set as callbacks by the tooltip itself. Not setting a function uses the library default.

Examples

Handler matching on arg

local function myHandlerFunc(cell, arg, event)
        local btn
        if arg == "b1" then
               btn = "#1"
        elseif arg == "b2" then
               btn = "#2"
        elseif arg == "b3" then
               btn = "#3"
        end
        DEFAULT_CHAT_FRAME:AddMessage("You pressed button "..btn)
end

local function myFunc()
        tooltip = QTC:Acquire("MyAddonNameTooltip", 3, "LEFT", "LEFT", "CENTER")
        -- Assign the callback to the tooltip
        tooltip:SetCallback("OnMouseDown", myHandlerFunc)
        local y, x = tooltip:AddLine()
        y, x = tooltip:SetCell(y, 1, "Button 1", "b1")
        y, x = tooltip:SetCell(y, 2, "Button 2", "b2")
        y, x = tooltip:SetCell(y, 3, "Button 3", "b3")
        tooltip:Show()
end

Handler using a function

local function myHandlerFunc(cell, arg, event)
        local text = arg()
        DEFAULT_CHAT_FRAME:AddMessage(text)
end

local function myFunc()
        tooltip = QTC:Acquire("MyAddonNameTooltip", 3, "LEFT", "LEFT", "CENTER")
        -- Assign the callback to the tooltip
        tooltip:SetCallback("OnMouseDown", myHandlerFunc)
        local y, x = tooltip:AddLine()
        y, x = tooltip:SetCell(y, 1, "Button 1", function() return "You pressed button 1!" end)
        y, x = tooltip:SetCell(y, 2, "Button 2", function() return "You pressed button 2!" end)
        y, x = tooltip:SetCell(y, 3, "Button 3", function() return "You pressed button 3!" end)
        tooltip:Show()
end

Handler using mixed conventions

local function myHandlerFunc(cell, arg, event)
       if type(arg) == "function" then
               arg()
       elseif type(arg) == "table" then
               DEFAULT_CHAT_FRAME:AddMessage(arg.message)
               arg.func()
       elseif arg == "b1" then
               DEFAULT_CHAT_FRAME:AddMessage("You pressed button #1")
       end
end

local function myFunc()
        -- I assume that by now this part is unnecessary
end


Comments

Posts Quoted:
Reply
Clear All Quotes