by 'custom button' I mean:
Code:
local button = CreateFrame("Button", "GenericButtonName", UIParent, "SecureActionButtonTemplate, SecureHandlerDragTemplate")
-- Set the spell attributes on the button
button:SetAttribute("type", "spell")
button:SetAttribute("spell", theSpell)
button:RegisterForDrag("LeftButton", "RightButton")
button:EnableMouse(true)
-- ###################
-- SET THE BUTTONS TEXTURE
-- ###################
local t = button:CreateTexture(nil, "BACKGROUND")
t:SetTexture(GetSpellTexture(theSpell))
t:SetAllPoints(button)
button.IconFrameIcon = t
I excluded some of the OnEnter mouse over tool tip stuffs, but I'm sure ya'll get the idea. But my problem is when I would like to add the ability to Shift-Click & Drag the spell off the button, so it can be replaced. Now, the above button is a permanent thing, so it cannot be 'picked up', so to do it, I used the following:
Code:
button:SetScript("PreClick", function()
-- For shift-clicking a spell off the bar
if IsShiftKeyDown() then
if UnitAffectingCombat("player") then
print("You cannot do that while in combat due to restrictions in the WoW UI.")
return
else
PickupSpell(tostring(theSpell or ""))
end
end
end)
Unfortunately, it does not work. Well, the picking up the spell part works, but if the above code is enabled, then the button loses it's click to cast ability. And is rendered to be just a square with a spell icon that can be picked up with a shift-click. Anyone with any experience to the above care to chime in what I'm doing wrong?