Jump to content

Multiparm callbacks


reyan

Recommended Posts

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.
image.png.e280d6719b1551b8f99129efacd3118c.png

Link to comment
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():
		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 by JXS
  • Like 1
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...