May I ask why this code goes into stack overflow
Lua Code:
local function SetWidgetScript(frame,method)
if frame:IsShown() then
for i = 1, #frame.buttons do
frame.buttons[i]:HookScript("OnMouseDown", method)
end
else
frame:SetScript(
"OnShow", --when "OnShow" is fired, IsShown() become true
SetWidgetScript(frame,method)
)
end
end
While it works fine by simply wrapping myfunc() inside the function environment after "OnShow"?
Lua Code:
local function SetWidgetScript(frame,method)
if frame:IsShown() then
for i = 1, #frame.buttons do
frame.buttons[i]:HookScript("OnMouseDown", method)
end
else
frame:SetScript(
"OnShow", --when "OnShow" is fired, IsShown() become true
function()
SetWidgetScript(frame,method)
end
)
end
end