Thread Tools Display Modes
05-21-20, 02:08 AM   #1
Spyro
A Fallenroot Satyr
 
Spyro's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2011
Posts: 23
Question 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?
  Reply With Quote
05-21-20, 06:32 AM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
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)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Executing secure code on a RaidFrame click

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off