Ok. Please ignore my post below (can' delete it?). I just realized that tables are restricted and solved my Problem with
kids = table.new(self:GetChildren())
Thanks for peeking in
-------------------------------------------------
I currently trying to familiarize myself with the secure frame stuff. (no fun at all ... feels really complicated and undocumented)
My very first steps are this:
Lua Code:
local bar = CreateFrame("Frame", "TestBar", UIParent, "SecureHandlerStateTemplate")
bar:SetPoint("CENTER", UIParent, "CENTER")
bar:SetSize(120, 50)
bar:SetBackdrop({bgFile="Interface\\Tooltips\\UI-Tooltip-Background", edgeFile="Interface\\Tooltips\\UI-Tooltip-Border", tile = false, tileSize = 1, edgeSize = 10, insets = { left = 0, right = 0, top = 0, bottom = 0 }})
bar:SetAttribute('_onstate-stance', [[
local btn = self:GetFrameRef('TestButton1')
if btn then
print(btn:GetName())
end
local kids
self:GetChildList(kids)
if kids then
for i, v in ipairs(kids) do
print(i)
end
end
]])
RegisterStateDriver(bar, "stance", "[stance:0] stance0; [stance:1] stance1; [stance:2] stance2; [stance:3] stance3; [stance:4] stance4; [stance:5] stance5;")
local TestButton1 = CreateFrame("CheckButton", "TestButton1", bar, "SecureHandlerClickTemplate, ActionButtonTemplate")
TestButton1:SetPoint("LEFT", bar, "LEFT")
TestButton1:SetSize(40, 40)
TestButton1:EnableMouse(true)
TestButton1:RegisterForClicks("AnyUp")
TestButton1:SetAttribute("_onclick", [[
print(self:GetParent():GetName())
]])
local TestButton2 = CreateFrame("CheckButton", "TestButton2", bar, "SecureHandlerClickTemplate, ActionButtonTemplate")
TestButton2:SetPoint("LEFT", bar, "LEFT", 50, 0)
TestButton1:SetSize(40, 40)
TestButton2:EnableMouse(true)
TestButton2:RegisterForClicks("AnyUp")
TestButton2:SetAttribute("_onclick", [[
print(self:GetParent():GetName())
]])
bar:SetFrameRef("TestButton1", TestButton1)
bar:SetFrameRef("TestButton2", TestButton2)
This code fails on GetChildList with
Code:
14x FrameXML\RestrictedExecution.lua:397: Call failed: FrameXML\RestrictedFrames.lua:197: attempt to get length of local "result" (a nil value)
<in C code>
FrameXML\RestrictedExecution.lua:397: in function <FrameXML\RestrictedExecution.lua:390>
(tail call): ?
(tail call): ?
FrameXML\SecureHandlers.lua:113: in function <FrameXML\SecureHandlers.lua:108>
<in C code>
FrameXML\SecureStateDriver.lua:114: in function <FrameXML\SecureStateDriver.lua:95>
FrameXML\SecureStateDriver.lua:164: in function <FrameXML\SecureStateDriver.lua:146>
<in C code>
FrameXML\SecureStateDriver.lua:11: in function <FrameXML\SecureStateDriver.lua:8>
(tail call): ?
BAB-0.0.1\Core.lua:1501: in main chunk
Locals:
workingEnv = <userdata>
ctrlHandle = <userdata>
pcallFlag = false
LOCAL_Function_Environment_Manager = <function> defined @Interface\FrameXML\RestrictedExecution.lua:209
error = <function> defined =[C]:-1
tostring = <function> defined =[C]:-1
As this is my very first try to do something with the complex secure handler thingi I have no idea what's wrong.
I took GetChildList() from Iriel’s Field Guide to Secure Handlers which states:
<...>Handles can be obtained for other frames as well through the following mechanisms:
• Via the return values from the handle:GetParent(), handle:GetChildren(), and handle:GetChildList(tbl) methods.<...>
Could anyone please show me what I'm doing wrong? I'm lost.