reyan Posted December 2, 2021 Share Posted December 2, 2021 Hello magicians, there's a way to put different callbacks on those buttons in the multiparm folder ? Quote Link to comment Share on other sites More sharing options...
acey195 Posted December 10, 2021 Share Posted December 10, 2021 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. Quote Link to comment Share on other sites More sharing options...
JXS Posted December 15, 2021 Share Posted December 15, 2021 (edited) 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(): print("Hi") def bye(): print("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 December 15, 2021 by JXS 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.