It should be executing /sit on leftbutton, but not rightbutton
Lua Code:
local frame = CreateFrame("Frame", "Test", UIParent, "SecureHandlerStateTemplate")
frame:SetSize(40, 40)
frame:SetPoint("TOPLEFT", UIParent, 10, -150)
local button = CreateFrame("Button", "TestBtn", frame, "SecureActionButtonTemplate")
button:ClearAllPoints()
button:SetSize(32, 32)
button:SetPoint("CENTER", frame)
local texture = button:CreateTexture("$parent_tex", "BACKGROUND")
texture:SetAllPoints(true)
texture:SetTexture(GetSpellTexture(783))
button.texture = texture
button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
button:SetAttribute("type1", "macro")
button:SetAttribute("type2", "macro")
button:SetAttribute("macrotext", "/sit")
button:SetScript("PostClick", function(self, arg1)
print("POSTCLICK: Clicked button=", self:GetName(), arg1, " macroTxt=", self:GetAttribute("macrotext"))
end)
Added
Code:
button:SetAttribute("type2", "macro")
for rightbutton.
For information on click attributes (Modified attributes)
see