2

I currently try to solve the following problem: I create a slider and a parameter during runtime inside of an agent. Now I would like to link the slider to the parameter. However, I am not able to find API code to solve this in a straightforward manner. I`ve looked through the Java interface. It seems that I need to add this function manually as a function executeShapeControlAction(). I try to avoid writing code directy in the JAVA interface. So I am curious about the easiest ways to connect a during runtime created slider with an already existing parameter.

Thank you!

JHK
  • 51
  • 5

1 Answers1

3

Every parameter generates a "set_" function for you. Assume your parameter is called myParam. Then you can change it at runtime by calling set_myParam(somevalue).

Use that in your slider action as set_myParam(value) and your slider value will change the parameter.

cheers

Benjamin
  • 10,603
  • 3
  • 16
  • 28
  • Thank you. But how can in a set the action of slider programmatically. I`ve created the slider object and added it to the presentable. However, I still struggle with calling the right function to set the slider action accordingly. How can this be done? – JHK Apr 21 '20 at 21:40
  • @JHK Sliders have a `setValue(newValue, callAction)` function. make sure the second argument is "true" to ensure that the action code is executed as well. This will ensure your param is changed as well (if your slider has the proper action code as defined in my answer. – Benjamin Apr 22 '20 at 19:25
  • @ Benjamin Thank you for the reply. But this is not the problem I actually face. I am looking for the particular code to programmatically set the action for the programmatically created slider. I am just able to implement `set_myParam(value)` as action via GUI. However, I would like to do this via code. Is this even possible? Thank you very much! – JHK Apr 22 '20 at 22:18
  • Why would you want to create a slider programmatically? Don't go there. Create an empty agent with a pre-defined slider and use that, if really needed. – Benjamin Apr 23 '20 at 12:10