Based on the example on this page
https://wowpedia.fandom.com/wiki/Sec...ButtonTemplate
Have you tried changing type and macrotext to type1 and macrotext1 for left button click as these are attributes as SDPhantom mentioned. Although, I think ( not 100% sure ), that left button is default so maybe macrotext with no number is treated as macrotext1 :shrugs:
Just tested this version of your code using your original sit test on the PTR just now ( there was a big update ) and it worked
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)) -- "Travel Form"
button.texture = texture
button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
button:SetMouseClickEnabled(true)
button:SetAttribute("type1", "macro")
button:SetAttribute("macrotext1", "/sit")
------ testing purpose
button:SetScript("PostClick", function(self, arg1)
print("POSTCLICK: Clicked button=", self:GetName(), " macroTxt=", self:GetAttribute("macrotext1"))
end)