View Single Post
09-23-22, 03:01 AM   #14
Zax
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 147
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:
  1. local frame = CreateFrame("Frame", "Test", UIParent, "SecureHandlerStateTemplate")
  2.     frame:SetSize(40, 40)
  3.     frame:SetPoint("TOPLEFT", UIParent, 10, -150)
  4.      
  5.     local button = CreateFrame("Button", "TestBtn", frame, "SecureActionButtonTemplate")
  6.     button:ClearAllPoints()
  7.     button:SetSize(32, 32)
  8.     button:SetPoint("CENTER", frame)
  9.     local texture = button:CreateTexture("$parent_tex", "BACKGROUND")
  10.     texture:SetAllPoints(true)
  11.     texture:SetTexture(GetSpellTexture(783)) -- "Travel Form"
  12.     button.texture = texture
  13.  
  14.     button:SetMouseClickEnabled(true) -- Make sure OnClick is enabled
  15.     --button:RegisterForClicks("LeftButtonUp", "LeftButtonDown", "RightButtonUp", "RightButtonDown")
  16.     -- button:RegisterForClicks("AnyUp", "AnyDown") -- up and down required for SecureActionButtonTemplate
  17.     button:RegisterForClicks("LeftButtonUp", "LeftButtonDown") -- up and down required for SecureActionButtonTemplate
  18.    
  19.     button:SetAttribute("type", "macro")
  20.     button:SetAttribute("macrotext1", "/sit")
  21.      
  22.     ------ testing purpose
  23.     button:SetScript("PostClick", function(self, btn, down)
  24.         if (down) then print("POSTCLICK: Clicked button=", self:GetName(), "  btn=", btn, "  down=", down, "  macroTxt=", self:GetAttribute("macrotext1")) end
  25.     end)
__________________
Zax - Addons List, not all maintained.

Last edited by Zax : 09-23-22 at 03:11 AM.
  Reply With Quote