First you need to have a button frame that inherits the SecureActionButtonTemplate
Code:
<Button name="NAMEOFYOURBUTTONFRAME" hidden="false" enableMouse="true" inherits="SecureActionButtonTemplate">
Also in your XML file, you need to set up script handlers for user clicks. Add this to your OnLoad handler area
Code:
this:RegisterForClicks("LeftButtonUp", "RightButtonUp")
Some other buttons presses you can check for
RegisterForClicks
Now for the LUA parts.
The SetAttribute function is what you will use to to get your button to "work".
Secure Frames Overview
This is just an example of how you CAN set it up when your addon loads (put in the function called when OnLoad happens)
Code:
function YOURADDON_OnLoad()
NAMEOFYOURBUTTONFRAME:SetAttribute("unit", "player")
NAMEOFYOURBUTTONFRAME:SetAttribute("type", "item")
NAMEOFYOURBUTTONFRAME:SetAttribute("item", "Netherweave Bandage")
NAMEOFYOURBUTTONFRAME:SetAttribute("shift-item", "Runecloth Bandage")
end
You could also try it this way
Code:
function YOURADDON_OnLoad()
NAMEOFYOURBUTTONFRAME:SetAttribute("unit", "player")
NAMEOFYOURBUTTONFRAME:SetAttribute("type", "macro")
NAMEOFYOURBUTTONFRAME:SetAttribute("macrotext", "/cast [modifier:shift] Runecloth Bandage; /cast [nomodifier:shift] Netherweave Bandage")
end
You probably dont need all this info but I thought it couldnt hurt to be thorough