Thread: Stack overflow
View Single Post
01-10-24, 07:29 AM   #3
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
The original code was

Lua Code:
  1. local function SetWidgetScript(frame,method)
  2.     if frame:IsShown() then
  3.         for i = 1, #frame.buttons do
  4.             frame.buttons[i]:HookScript("OnMouseDown", method)
  5.         end
  6.     else
  7.         frame:SetScript(
  8.             "OnShow", function()
  9.                  for i = 1, #frame.buttons do
  10.                      frame.buttons[i]:HookScript("OnMouseDown", method)
  11.                  end
  12.             end
  13.         )
  14.     end
  15. end

I changed the method in the "OnShow" script just to not repeat the for i=1...end part twice.
There is probably a better way to write a DRY script.
  Reply With Quote