Skip to main content
Byron Nash - INSP
Inspiring
August 16, 2022
Question

Calling a function from onClick

  • August 16, 2022
  • 2 replies
  • 631 views

I have a scriptUI palette I'm working on. Making progress but now my button won't run the function. Is this correct?

 

            myPanel.grp.groupOne.groupTwo.createSnipesButton.onClick = function() {
                alert("trying to run the function");
                createSnipes();
                }

then my function should run when that button is clicked. I have this dialog stuff happening in a function and the createSnipes() function is outside this. Does something need to happen differently? Maybe it can't reach outside itself?

I collapsed all the functions so you can see the top level structure. 

This topic has been closed for replies.

2 replies

Byron Nash - INSP
Inspiring
August 17, 2022

I cannot get my functions to call now. If I nest them in the function I'm in it works, but if I leave them all at a higher level they won't run. I can't keep nesting functions inside of other functions because many are reused throughout the script. I tried to write one of them to a separate file and use #include but it does not seem to work either. What am I doing wrong?

Inspiring
August 17, 2022

Try declaring res.

Put "var" before res.

Inspiring
August 17, 2022

Also, #target not required, i generally don't use as i run the script from File> script > run script.