The goal is to create a very simple addon able to keep track of the materials I want to farm. ATM, however, there are two contrasting effects: if I enable drag'n drop in the buttons (drag the item from the bag to the button, in order to keep track of it), the object tooltip is not displayed. By setting the "hidden" parameter to "true" in XML code, the tooltip becomes visible but it is no longer possible to drag 'n dop.
Is it possible to resolve this conflict?
LUA code:
Lua Code:
function UnitFarm:barUpdate() -- Bar group creation
for b, key in ipairs(db.profile["Bars"]) do
local f = _G["UnitFarm_Frame"..b] or CreateFrame("Frame", "UnitFarm_Frame"..b, UIParent, "UnitFarm_BarTemplate", b)
local scale = db.profile["Bars"][b].dimension
if (b == 1) then
f:SetPoint("CENTER",nil,"CENTER")
else
local abscissa = (b - 1) * (64 * scale)
local ordinate = (b - 1) * (72 * scale)
f:SetPoint("LEFT", nil, "LEFT", abscissa, ordinate)
end
db.profile["Bars"][b]["name"] = "Icon bar\32"..b
f:SetScale(scale)
if (not db.profile.Bars[b]["anchor"]) then db.profile.Bars[b]["anchor"] = {} end
local a = db.profile.Bars[b].anchor
if a.dragged then
f:ClearAllPoints()
f:SetPoint(a.point, nil, a.relative, a.x, a.y)
end
local total = db.profile["Bars"][b].columns * db.profile["Bars"][b].rows
UnitFarm:iconUpdate(total, f)
UnitFarm:iconLocation(b)
end
end
function UnitFarm:iconUpdate(total, frm)
local bar = frm:GetID()
for i = 1, total do
local f = UnitFarm:icon(bar, i) or CreateFrame("Button", frm:GetName().."UnitFarm_Icon"..i, frm, "UnitFarm_IconTemplate", i)
if (i == 1) then
f:SetPoint("LEFT",150,0)
else
local j = i - 1
f:SetPoint("TOPLEFT", UnitFarm:icon(j, bar) ,"TOPRIGHT",0,0)
end
f:RegisterForClicks("LeftButtonUp")
local tooltip = f.tooltip
tooltip:SetScript("OnEnter", function(self, button)
GameTooltip:SetOwner(tooltip, "ANCHOR_CURSOR")
GameTooltip:AddLine(db.profile["Bars"][frm:GetID()][i].item)
GameTooltip:Show()
end
)
tooltip:SetScript("OnLeave", function(self, button)
GameTooltip:Hide()
end
)
local function onReceive(self)
local infoType, arg1, arg2 = GetCursorInfo()
if infoType=="item" then
print(infoType, arg1, arg2)
local itemName, _, _, _, _, _, _, _, _, itemTexture = GetItemInfo(arg2)
db.profile["Bars"][frm:GetID()][i].item = itemName
ClearCursor()
end
end
f:SetScript("OnReceiveDrag",onReceive)
f:SetScript("OnClick",onReceive)
local columns = db.profile["Bars"][bar]["columns"]
local rows = db.profile["Bars"][bar]["rows"]
local width = (f:GetWidth() * columns) + (db.profile.Hspacing * (columns - 1)) - 1
local height = (f:GetHeight() * rows) - (db.profile.Vspacing * (rows - 1)) - 1
frm:SetClampRectInsets(0, width, 0, -height)
f.charge:SetFont("Fonts\\FRIZQT__.TTF", 24, "OUTLINE")
f.charge:SetTextColor(0.25,0.78,0.92)
end
end
XML code:
Code:
<Button name="UnitFarm_IconTemplate" virtual="true" enableMouse="true" enableKeyboard="true">
<Size>
<AbsDimension x="48" y="48"/>
</Size>
<Layers>
<!-- <Layer level="HIGHLIGHT">
<Texture name="$parentHighlight" parentKey="highlight" file="Interface\Buttons\CheckButtonHilight" alphaMode="ADD" setAllPoints="true">
<Size>
<AbsDimension x="30" y="30"/>
</Size>
</Texture>
</Layer> -->
<Layer level="ARTWORK">
<Texture name="$parentIcon" parentKey="texture" file="Interface\PaperDoll\UI-Backpack-EmptySlot.blp" setAllPoints="true">
<Anchor point="TOPLEFT" relativeTo="$parent" relativePoint="TOPLEFT"/>
</Texture>
</Layer>
<Layer level="OVERLAY">
<FontString name="$parentCharge" parentKey="charge" inherits="GameFontNormal" justifyH="RIGHT">
<Anchors>
<Anchor point="BOTTOMRIGHT" relativeTo="$parent" relativePoint="BOTTOMRIGHT">
<Offset>
<AbsDimension x="-2" y="2"/>
</Offset>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Scripts>
<OnLoad>
self:RegisterForDrag("LeftButton");
</OnLoad>
<OnDragStart>
self:GetParent():StartMoving();
</OnDragStart>
<OnDragStop>
UnitFarm:OnDragStop(self, button);
</OnDragStop>
<OnMouseDown>
UnitFarm_ButtonOnMouseDown(self, button);
</OnMouseDown>
<OnHide>
self:GetParent():StopMovingOrSizing();
</OnHide>
</Scripts>
<Frames>
<Frame name="$parent_UnitFarmDropDown" inherits="UIDropDownMenuTemplate" enableMouse="true" hidden="true">
<Anchors>
<Anchor point="TOP"/>
</Anchors>
<Scripts>
<OnLoad>
UnitFarm_DropDownOnLoad(self)
</OnLoad>
<OnShow>
UnitFarm_DropDownOnLoad(self)
</OnShow>
</Scripts>
</Frame>
<Frame name="$parentTooltip" parentKey="tooltip" enableMouse="true" setAllPoints="true" hidden="true"/>
</Frames>
<!-- <HighlightTexture alphaMode="ADD" file="Interface\Buttons\ButtonHilight-Square"/> -->
</Button>