View Single Post
05/01/14, 04:14 AM   #4
Harven
 
Harven's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 135
Originally Posted by arkemiffo View Post
... it's just that the counter in the handler doesn't seem to be saved by iteration in each instance of the button creation, but all of the buttons hold the number 12 (which is the last iteration of the var counter). ...
It's because function in OnMouseDown is called within a closure (read here). You must do it that way:
Code:
local c = counter
EffectButtonControl:SetHandler("OnMouseDown", function(self) NotebookOnChange(c) end)
  Reply With Quote