|
|
#1 |
|
Moderator
|
I have abandoned LibQTipClick-1.0 due to the fact that it was never developed past the proof-of-concept stage, yet started to get some use by addons. To that effect, I am releasing LibQTipClick-1.1 which addresses that fact - and the result is not backward-compatible.
New features: * The OnMouseDown() handler recognizes which mouse button is pressed. * The OnMouseUp() handler has been added. * The :SetNormalCell() function has been added. * The library has its own methods for the occasion when the default OnEnter() and OnLeave() are replaced. * Much better documentation.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of Revelation, Spamalyzer, Volumizer, and many other AddOns. Last edited by Torhal; 05-20-2009 at 08:01 AM. |
|
|
|
|
|
#2 |
|
Hero Member
Join Date: Sep 2006
Posts: 645
|
something is wrong with the new version
following your example using QTC:SetCallback(tooltip, "OnMouseDown", MouseHandler) throws a string expected error since the first part of that should be "OnMouseDown" instead of tooltip. if i remove the tooltip arg and just use QTC:SetCallback("OnMouseDown", MouseHandler) i get the "No function defined." message printed in my chat but everything works as expected (though i am not sure that this will work with multible addons using QTC since it seams to me that i am registering this for every event not just for my tooltip |
|
|
|
|
|
#3 |
|
Moderator
|
If I used a colon in my example, I fucked up.
![]() It should be: Code:
QTC.SetCallback(tooltip, "OnMouseDown", MouseHandler)
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of Revelation, Spamalyzer, Volumizer, and many other AddOns. Last edited by Torhal; 05-20-2009 at 07:09 AM. |
|
|
|
|
|
#4 |
|
Hero Member
Join Date: Sep 2006
Posts: 645
|
kk that makes sense
also another documentation fix: it should be QTC.OnLeave(event, cell, arg) instead of QTC.OnLeave(cell) if you want the highlighting back (same goes for the OnEnter function) |
|
|
|
|
|
#5 |
|
Moderator
|
Bah!
Thanks ![]()
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of Revelation, Spamalyzer, Volumizer, and many other AddOns. |
|
|
|
|
|
#6 |
|
Hero Member
Join Date: Sep 2006
Posts: 645
|
alright did some more testing and found a big problem if you have more than one QTC and they register call backs then they will all receive them so addon A with tooltip A will receive callbacks from Addon B with tooltip B and vica versa
also why are you using the callbacks for internal events? why not simply put your code directly in the events then you don't have the overhead of the callback and everything works like it should when others register for callbacks one solution would be to register callbacks per tooltip not on the lib you would then keep the tooltips stored in QTC instead of releasing them to QT Last edited by yssaril; 05-20-2009 at 07:56 AM. Reason: idea :P |
|
|
|
|
|
#7 |
|
Moderator
|
Ok, try it now, with the old SetCallback method:
Code:
tooltip:SetCallback("OnMouseDown", MouseHandler)
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of Revelation, Spamalyzer, Volumizer, and many other AddOns. |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jul 2006
Location: France
Posts: 387
|
now that LibQTipClick support recognition of the mouse pressed with the OnMouseDown handler I will look into using LibQTipClick instead of a custom provider.
But there are still two things that will require a custom cell provider for tomQuest2, maybe they can be part of LibQTip or LibQTipClick: * add custom left / right cell padding * maximum cell width after which the content of the cell will be splitted into multiple lines I think that both features are great to enhance the appearance of the tooltip and might be usefull ![]() Code:
local cProvider, cPrototype, basecCellPrototype = LibQTip:CreateCellProvider(LibQTip.LabelProvider)
function cPrototype:InitializeCell()
self.fontString = self:CreateFontString()
self.fontString:SetFontObject(GameTooltipText)
end
function cPrototype:SetupCell(tooltip, value, justification, font, maxWidth, indent)
indent = indent or 0
local width, height = basecCellPrototype.SetupCell(self, tooltip, value, justification, font)
local fs = self.fontString
fs:SetPoint("TOPLEFT", self, "TOPLEFT", indent, 0)
fs:SetPoint("BOTTOMRIGHT", self, "BOTTOMRIGHT", 0, 0)
width = width + indent
if width > maxWidth then
fs:SetWidth(maxWidth)
height = fs:GetHeight()
width = maxWidth
end
fs:Show()
return width, height
end
function cPrototype:ReleaseCell()
self:ClearAllPoints()
end
|
|
|
|
|
|
#9 | |
|
Hero Member
Join Date: Sep 2006
Posts: 645
|
am getting an error when ever i release the tooltip with the latest version
Quote:
the SetCallback i simply removed since it is just a wrapper and we can change the register functions via CBH directly so Code:
tooltip.callbacks = CBH:New(tooltip) Code:
tooltip.callbacks = tooltip.callbacks or CBH:New(tooltip, "SetCallback", "UnSetCallback", "UnSetAllCallback" or false) Code:
tooltip.RegisterCallback(tooltip, ... Code:
tooltip:RegisterCallback(... Code:
tooltip.UnRegisterAllCallbacks() Code:
tooltip:UnSetAllCallback(tooltip) here is what my total code came out to be Code:
local MAJOR = "LibQTipClick-1.1"
local MINOR = 1
assert(LibStub, MAJOR.." requires LibStub")
local lib, oldminor = LibStub:NewLibrary(MAJOR, MINOR)
if not lib then return end -- No upgrade needed
local QTip = LibStub:GetLibrary("LibQTip-1.0")
assert(QTip, MAJOR.." requires LibQTip-1.0")
local CBH = LibStub:GetLibrary("CallbackHandler-1.0")
assert(CBH, MAJOR.." requires CallbackHandler-1.0")
-------------------------------------------------------------------------------
-- Local variables
-------------------------------------------------------------------------------
lib.LabelProvider, lib.LabelPrototype, lib.BaseProvider = QTip:CreateCellProvider(QTip.LabelProvider)
local cell_provider, cell_prototype, cell_base = lib.LabelProvider, lib.LabelPrototype, lib.BaseProvider
-------------------------------------------------------------------------------
-- Public library API
-------------------------------------------------------------------------------
function lib.OnEnter(event, cell, arg)
if not cell.highlight then
cell.highlight = cell:CreateTexture(nil, "BACKGROUND")
cell.highlight:Hide()
end
cell.highlight:SetTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
cell.highlight:SetBlendMode("ADD")
cell.highlight:SetAllPoints(cell)
cell.highlight:Show()
end
function lib.OnLeave(event, cell, arg)
if cell.highlight then
cell.highlight:ClearAllPoints()
cell.highlight:Hide()
end
end
function lib.OnMouseDown(event, cell, arg, button) PlaySound("igMainMenuOpen") end
function lib.OnMouseUp(event, cell, arg, button) end
local function Cell_OnEnter(cell) cell.callbacks:Fire("OnEnter", cell, cell.arg) end
local function Cell_OnLeave(cell) cell.callbacks:Fire("OnLeave", cell, cell.arg) end
local function Cell_OnMouseDown(cell, button) cell.callbacks:Fire("OnMouseDown", cell, cell.arg, button) end
local function Cell_OnMouseUp(cell, button) cell.callbacks:Fire("OnMouseUp", cell, cell.arg, button) end
function cell_prototype:InitializeCell() cell_base.InitializeCell(self) end
function cell_prototype:SetupCell(tooltip, value, justification, font, arg, ...)
local width, height = cell_base.SetupCell(self, tooltip, value, justification, font, arg, ...)
self:EnableMouse(true)
self.arg = arg
self.callbacks = tooltip.callbacks
self:SetScript("OnEnter", Cell_OnEnter)
self:SetScript("OnLeave", Cell_OnLeave)
self:SetScript("OnMouseDown", Cell_OnMouseDown)
self:SetScript("OnMouseUp", Cell_OnMouseUp)
return width, height
end
function cell_prototype:ReleaseCell()
self:EnableMouse(false)
self:SetScript("OnEnter", nil)
self:SetScript("OnLeave", nil)
self:SetScript("OnMouseDown", nil)
self:SetScript("OnMouseUp", nil)
self.arg = nil
self.callbacks = nil
end
-------------------------------------------------------------------------------
-- LibQTip wrapper API
-------------------------------------------------------------------------------
local function AddNormalLine(tooltip, ...)
local oldProvider = tooltip:GetDefaultProvider()
tooltip:SetDefaultProvider(QTip.LabelProvider)
local lineNum, colNum = tooltip:AddLine(...)
tooltip:SetDefaultProvider(oldProvider)
return lineNum, colNum
end
local function AddNormalHeader(tooltip, ...)
local oldProvider = tooltip:GetDefaultProvider()
tooltip:SetDefaultProvider(QTip.LabelProvider)
local lineNum, colNum = tooltip:AddHeader(...)
tooltip:SetDefaultProvider(oldProvider)
return lineNum, colNum
end
local function SetNormalCell(tooltip, ...)
local oldProvider = tooltip:GetDefaultProvider()
tooltip:SetDefaultProvider(QTip.LabelProvider)
local lineNum, colNum = tooltip:SetCell(...)
tooltip:SetDefaultProvider(oldProvider)
return lineNum, colNum
end
function lib:Acquire(key, ...)
local tooltip = QTip:Acquire(key, ...)
tooltip:EnableMouse(true)
tooltip.callbacks = tooltip.callbacks or CBH:New(tooltip, "SetCallback", "UnSetCallback", "UnSetAllCallback" or false)
tooltip:SetCallback("OnEnter", self.OnEnter)
tooltip:SetCallback("OnLeave", self.OnLeave)
tooltip:SetCallback("OnMouseDown", self.OnMouseDown)
tooltip:SetCallback("OnMouseUp", self.OnMouseUp)
tooltip.AddNormalLine = AddNormalLine
tooltip.AddNormalHeader = AddNormalHeader
tooltip.SetNormalCell = SetNormalCell
tooltip:SetDefaultProvider(cell_provider)
return tooltip
end
function lib:IsAcquired(key) return QTip:IsAcquired(key) end
function lib:Release(tooltip)
tooltip:EnableMouse(false)
tooltip:UnSetAllCallback(tooltip)
QTip:Release(tooltip)
end
function lib:IterateTooltips() return QTip:IterateTooltips() end
function lib:CreateCellProvider(baseProvider) return QTip:CreateCellProvider(baseProvider) end
|
|
|
|
|
|
|
#10 | ||
|
Moderator
|
Quote:
Quote:
I'll change the CallbackHandler usage to mirror the rest of your suggestions, but I'm making the unset-all be UnSetAllCallbacks (added the "s" on the end). ![]()
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of Revelation, Spamalyzer, Volumizer, and many other AddOns. Last edited by Torhal; 05-20-2009 at 11:56 PM. |
||
|
|
|
![]() |
«
Previous Thread
|
Next Thread
»
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|
All times are GMT. The time now is 04:09 PM.
WowAce Forums









