View Single Post
04-03-23, 11:32 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,906
It should be executing /sit on leftbutton, but not rightbutton

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.  
  10. local texture = button:CreateTexture("$parent_tex", "BACKGROUND")
  11. texture:SetAllPoints(true)
  12. texture:SetTexture(GetSpellTexture(783))
  13. button.texture = texture
  14.  
  15. button:RegisterForClicks("LeftButtonUp", "RightButtonUp")
  16. button:SetAttribute("type1", "macro")
  17. button:SetAttribute("type2", "macro")
  18. button:SetAttribute("macrotext", "/sit")
  19.  
  20. button:SetScript("PostClick", function(self, arg1)
  21.     print("POSTCLICK: Clicked button=", self:GetName(), arg1, "  macroTxt=", self:GetAttribute("macrotext"))
  22. end)

Added
Code:
button:SetAttribute("type2", "macro")
for rightbutton.

For information on click attributes (Modified attributes) see
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 04-03-23 at 11:44 AM.
  Reply With Quote