What I've done before is create a SecureActionButton that runs
/cancelform and put the
DoTradeSkill() call in a
PostClick handler. You can also do
button:HookScript() on the
OnClick handler to securely post-hook the existing script used by the SecureActionButtonTemplate.
Method 1:
Lua Code:
local button=CreateFrame("Button",nil,nil,"SecureActionButtonTemplate");
button:RegisterForClicks("AnyUp");
button:SetAttribute("type","macro");
button:SetAttribute("macrotext",SLASH_CANCELFORM1);-- Using this constant makes sure this code works on all locales
button:SetScript("PostClick",function(self,button)
-- Do stuff and make your DoTradeSkill() call here
);
Method 2:
Lua Code:
local button=CreateFrame("Button",nil,nil,"SecureActionButtonTemplate");
button:RegisterForClicks("AnyUp");
button:SetAttribute("type","macro");
button:SetAttribute("macrotext",SLASH_CANCELFORM1);-- Using this constant makes sure this code works on all locales
button:HookScript("OnClick",function(self,button)
-- Do stuff and make your DoTradeSkill() call here
);