WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Executing secure code on a RaidFrame click (https://www.wowinterface.com/forums/showthread.php?t=58011)

Spyro 05-21-20 02:08 AM

Executing secure code on a RaidFrame click
 
Hey.

I want to execute secure code (do a SetAttribute() on my own secure frame while In Combat) when the user clicks on a raid member on Blizzard's raid frames. The goal is to save on my secure frame the UnitID of the party/raid member that the user has targeted with his click.

My initial idea was to do something like:

Lua Code:
  1. MyTestXD = CreateFrame("Button", "MyTestXD", nil, "SecureHandlerClickTemplate")
  2. CompactRaidFrame1:SetFrameRef("Test", MyTestXD)
  3.  
  4. MyTestXD:WrapScript(CompactRaidFrame1, "PostClick", [[
  5.   local Test = self:GetFrameRef("Test")
  6.   Test:SetAttribute("UnitID", self:GetAttribute("unit"))
  7.   print("Unit targeted saved:", Test:GetAttribute("UnitID"))
  8. ]])

But trying it I have seen that CompactRaidFrames don't have SetFrameRef() method, so this approach is not possible.

Any ideas on how to do it?

Vrul 05-21-20 06:32 AM

You need a header that is like a middle man for everything:
Code:

local header = CreateFrame("Frame", nil, nil, "SecureHandlerStateTemplate")

MyTestXD = CreateFrame("Button", "MyTestXD", nil, "SecureHandlerClickTemplate")
header:SetFrameRef("Test", MyTestXD)

local preClick = [[
  local Test = control:GetFrameRef("Test")
  Test:SetAttribute("UnitID", self:GetAttribute("unit"))
  print("Unit targeted saved:", Test:GetAttribute("UnitID"))
]]

header:WrapScript(CompactRaidFrame1, "OnClick", preClick)



All times are GMT -6. The time now is 12:09 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI