-
Posted by neo angelus on Fri, 15 Apr 2011 15:34:27
Greetings Everyone,
Today I started creating addons for WoW. So far so good and I've started creating a healing-addon. It works so far with displaying coloured SecureActionButtonTemplate-button for every member in your party or raid. (Only tested parties though.)
But now I've run into a bind and I can't get the right(or any other button then the left) to work for casting spells. I searched a lot and tried a few different approaches but still no progress. Left-click works perfect and does what I want it to do, but right click fails.
This is what I use when I create a button:
local function createButton(frame) local button = CreateFrame("Button", "ButtonX", frame, "SecureActionButtonTemplate"); button:SetWidth(64); button:SetHeight(32); button.texture = texture; button:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 16, edgeSize = 16, insets = { left = 4, right = 3, top = 4, bottom = 3 }}); button:SetBackdropColor(0.2, 0.5, 0.2, 0.9); --button:SetPoint("CENTER",0,0); table.insert(buttons, button); button:SetNormalFontObject("GameFontHighlight"); local font = button:GetNormalFontObject(); font:SetTextColor(1, 0.5, 0.25, 1.0); button:SetNormalFontObject(font); return button; end
After that I edit the returned button using:
local function _setButtons(frame, partyData) local currentButtons = #buttons; visibleButtons = #partyData; for i, p in pairs(partyData) do if (i>currentButtons) then createButton(frame); if(i>1) then buttons[i]:SetPoint("LEFT",buttons[i-1],"RIGHT",3, 0); else buttons[i]:SetPoint("LEFT",frame, 10, 0); end end buttons[i]:SetText(p.name); buttons[i]:SetAttribute("unit", p.uid); buttons[i]:SetAttribute("type1", "spell"); buttons[i]:SetAttribute("spell1", "Flash of Light"); buttons[i]:SetAttribute("type2", "spell"); buttons[i]:SetAttribute("spell2", "Holy Light"); buttons[i]:Show(); end if(visibleButtons<currentButtons) then for i=visibleButtons+1, currentButtons do buttons[i]:Hide(); end end _resize(); end
It recycles buttons for when the party increases, decreases and increases again. That is the only point in the code where I use SetAttribute.
I would be ever so grateful if anybody could help me with this! (I'm playing on OS X, using the steelseries Cataclysm mouse. with a Draenei Paladin.)
-
Posted by Cayenne on Fri, 15 Apr 2011 16:58:35
Try adding an appropriate call to RegisterForClicks somewhere.
-
Posted by neo angelus on Fri, 15 Apr 2011 21:03:34
Perfect that was exactly what was missing! Thank you so very much! (Now everything works perfectly!)
Never read about it, but still...sorry I didn't know.
-
Posted by jnwhiteh on Sat, 16 Apr 2011 05:12:00
There is a chapter that does exactly what you're doing in case you want to look at that and see explanations of everything. I'm glad you got it working!
-
Posted by neo angelus on Mon, 18 Apr 2011 07:31:14
Thank you! Can't read the book yet though, it has been ordered but takes a while to deliver. (7-14 days.)