WoWInterface (
-   Lua/XML Help (
-   -   Executing secure code on a RaidFrame click (

Spyro 05-21-20 02:08 AM

Executing secure code on a RaidFrame click

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)
  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:

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 05:51 PM.

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