OK, I'm now able to
/sit
SDPhantom is right: both up and down listener are required for SecureActionButtonTemplate.
EDIT:
As PostClick debugging is now printed twice, I had to add a test before performing PostClick actions.
This is the actual /sit button. I'll test with ground markers this evening and keep you informed.
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:SetMouseClickEnabled(true) -- Make sure OnClick is enabled
--button:RegisterForClicks("LeftButtonUp", "LeftButtonDown", "RightButtonUp", "RightButtonDown")
-- button:RegisterForClicks("AnyUp", "AnyDown") -- up and down required for SecureActionButtonTemplate
button:RegisterForClicks("LeftButtonUp", "LeftButtonDown") -- up and down required for SecureActionButtonTemplate
button:SetAttribute("type", "macro")
button:SetAttribute("macrotext1", "/sit")
------ testing purpose
button:SetScript("PostClick", function(self, btn, down)
if (down) then print("POSTCLICK: Clicked button=", self:GetName(), " btn=", btn, " down=", down, " macroTxt=", self:GetAttribute("macrotext1")) end
end)