I think the SecureHandlerClickTemplate template is for creating click-cast unit frames, not for making action buttons. Also, to get click handlers your frame must be a Button, not a regular Frame. Try this instead:
Code:
local f = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate")
Then, you can make it do things when clicked by setting its attributes, like this:
Code:
f:SetAttribute( "type1", "spell" )
f:SetAttribute( "spell1", "Frost Shock" )
Or, if you want to run some code instead of casting a spell:
Code:
f:SetAttribute( "type1", "macro" )
f:SetAttribute( "macrotext1", "/run MyButton:Hide()" )
Or, to run some code
and cast a spell:
Code:
f:SetAttribute( "type1", "macro" )
f:SetAttribute( "macrotext1", [[/cast Frost Shock
/run MyButton:Hide()]] )
In order to access the button from inside the macro though, you have to give it a global name:
Code:
local f = CreateFrame("Button", "MyButton", UIParent, "SecureActionButtonTemplate")
There’s some documentation about the SecureActionButton attributes in Blizzard’s SecureTemplates.lua file:
Code:
-- SecureActionButtons allow you to map different combinations of modifiers and buttons into
-- actions which are executed when the button is clicked.
--
-- For example, you could set up the button to respond to left clicks by targeting the focus:
-- self:SetAttribute("unit", "focus");
-- self:SetAttribute("type1", "target");
--
-- You could set up all other buttons to bring up a menu like this:
-- self:SetAttribute("type*", "menu");
-- self.showmenu = menufunc;
--
-- SecureActionButtons are also able to perform different actions depending on whether you can
-- attack the unit or assist the unit associated with the action button. It does so by mapping
-- mouse buttons into "virtual buttons" based on the state of the unit. For example, you can use
-- the following to cast "Mind Blast" on a left click and "Shadow Word: Death" on a right click
-- if the unit can be attacked:
-- self:SetAttribute("harmbutton1", "nuke1");
-- self:SetAttribute("type-nuke1", "spell");
-- self:SetAttribute("spell-nuke1", "Mind Blast");
-- self:SetAttribute("harmbutton2", "nuke2");
-- self:SetAttribute("type-nuke2", "spell");
-- self:SetAttribute("spell-nuke2", "Shadow Word: Death");
--
-- In this example, we use the special attribute "harmbutton" which is used to map a virtual
-- button when the unit is attackable. We also have the attribute "helpbutton" which is used
-- when the unit can be assisted.
--
-- Although it may not be immediately obvious, we are able to use this new virtual button
-- to set up very complex click behaviors on buttons. For example, we can define a new "heal"
-- virtual button for all friendly left clicks, and then set the button to cast "Flash Heal"
-- on an unmodified left click and "Renew" on a ctrl left click:
-- self:SetAttribute("*helpbutton1", "heal");
-- self:SetAttribute("*type-heal", "spell");
-- self:SetAttribute("spell-heal", "Flash Heal");
-- self:SetAttribute("ctrl-spell-heal", "Renew");
--
-- This system is very powerful, and provides a good layer of abstraction for setting up
-- a button's click behaviors.