Each text field has a OnEvent Callback function to retrieve its value whenever I click on it.
The issue is, that I can't bind variables inside the Loop to the call back function. No matter what is it in the Loop, it will only return 0 inside the callback.
The only workaround so far is to pass a Ctrl Object to the call-back function, then retrieve each Text Control Name and Text
Could you please tell me a way to bind variables (sorry for lack of a better word) from the Loop to the CallBackFunc()?
Here is my example:
Code: Select all
myGui := Gui()
loop 10
{
myText := myGui.Add("Text", "h33 w100 Left BackgroundTrans 0x201 vTextCtrl" . A_Index, "Hello world" . A_Index)
myText.OnEvent("Click", CallBackFunc)
CallBackFunc(CtrlObj, *)
{
MsgBox("Ctrl Name (correct): " . CtrlObj.Name . "`r`n Variables inside the loop (wrong): " . A_Index)
}
}
myGui.Title := "Testing Callback function"
myGui.Show("AutoSize")