I want to modify the value of every numeric entry field of a container dynamically.
For example, I have a container with 20 numeric entry fields and I want to set their value to 0 within a loop by pressing a button.
I don’t want to write one line of script for each component.
I want to loop in each component of my container without scripting their name.
Is it possible to do that ?
A message handler might also be worth looking into. Every numeric entry field can have a
resetValue message handler that set’s it’s own value to 0. Your script would then only have to send a
resetValue message to the appropriate scope to execute. This has the added advantage of allowing different behavior for different components if it’s appropriate.
Since you’re trying to limit yourself to one container, there may not be a scope specific enough for your purpose; I’m unsure.
This would be the way to do it. Thought 20 components and setting them all to zero seems like you could just hardcode it without much hassle.
Having experimented with this sort of thing before, you will want to come up with some conventions for your GUI to help make this process easier. Each component that you want to write to has a name with a certain prefix or suffix, or has a custom property that indicates it is to be updated by your script.
Having a project wide convention like “this prefix/suffix/boolean custom property “writeTo” with value True means this component is written to by this sort of function” can be very powerful, but without having it documented somewhere, in the future when it comes time to make a change, it can become more of a headache than just hardcoding it to begin with.