Pass a function when calling onClick for a button (UI)
Hi
I´m now studying and adventuring myself in the Script UI creation. I´m enjoying it !!!
I´m having the following trouble: I added a button to a dialog box and would like to tell script to run some commands when users click on the button. So this is a simple (poor example):
var dlg = new Window ("dialog", "My dialog", [0,0,0,0])
dlg.size = [500,500]
dlg.location = [300,300]
var b = dlg.add("button", [0,0,0,0], "Run")
b.location = [20, 180]
b.size = [80, 30]
dlg.show()
b.onClick = test () //the problem is here
function test(){
alert("teste")
}
-------
Everything is right. But the onClick event does not execute the function test I´m passing! What Am I missing?
I know if I use
b.onClick = function (){
...
}
It works...but I´d like the function to be called instead of directlly created when calling the onClick. Do not know if I´m able to explain it better.
Thank you for the help
Best Regards
Gustavo.
