Jump to content
Sign in to follow this  

Multiparm callbacks

Recommended Posts

Hello magicians, 
there's a way to put different callbacks on those buttons in the multiparm folder ? 


Share this post

Link to post
Share on other sites

clicking those buttons should trigger this callback script.
But I'm not aware of a built in way to trigger 2 different callback scripts for plus and minus.
To do that, I think you have to keep track of the previous number somewhere (which is also not super trivial I guess), and check if the new number is higher or lower than the previous one.

Share this post

Link to post
Share on other sites

I tried to wrap my head around this one but from my understanding, and if anyone with more exp on this could chime in, those buttons are tied to one parameter, namely, whatever your folder's name is. They themselves are not parameters (unless if you make two individual buttons but that's another thing entirely). As expected, when you increment, the script value (kwargs["script_value"]) goes up and vice versa with the - button, but all in all they are altering the same parameter, which means only one callback script...I think.

I contemplated the idea of perhaps using a callback script as an entry function and passing in the parameter values. The X/Clear button sets it to 0 by default and the +/- buttons move that value up/down respectively, so maybe you could attempt to feed that value as a key to a dictionary of functions or perhaps more simply, a simple if/else statement where if the value passed is 0, the function will call some nested function A(), and if the value passed is greater than 0, the function will call some nested function B(). Something like the following:

def entry_point(kw):
	def hi():
	def bye():
	hi() if int(kw) > 0 else bye()

Very simple example yes, but it works. Then in the callback script just type in something like the following: __import__(module_name_here).function_name(kwargs["script_value"].

Of course, now you have the issue that your first function will run regardless of whether you press the + or - button and if it's non-zero. The only way the second function will run is if the parameter value is 0. So, like @acey195 said, unless if there's a way to store the previous parameter value, like a global variable, and compare it to the new value, then no, there is no way to differentiate between the +/- buttons and attach different callback scripts to them. With the script above, maybe you could differentiate between the +/- and the X/Clear but at this point, you're probably better off achieving your original goal by simply dropping down two button parameters and attaching your callback scripts to them.

I'm certain that what you're asking for is doable, but probably not through a callback script, I think. Hopefully someone with more exp could chime in on this.

Edited by JXS
  • Like 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this