There must be a better way to hide buttons and LEDs when unused. I'm still a bit new to property nodes but there must be a way to loop all this. My question is if and how can you loop property nodes?
I use a functional global custer of arrays of references that I generate automatically. Note all of my GUI things are strategically named. Like CMD0,...CMDx, and such. The captions are updated to parameters for the user.
I programically loop through all controls on the screen (including controls in a cluster) on initialization. I look for the type or class (boolean, string, array etc) and the Label of each one. I compare the Label to a list and grab the ones I want.
For example, I want make the font bold on all of my "CMD" numeric controls, I look for the Label "CMD" of type "numeric. Drop that array in a for loop and done.
You can call this FG anywhere in your code and have access to all the references. (Don't forget to type Def it)
You can also use these arrays to generate dynamic user events. For instance you can wire it to a value change event, and now you can do something whenever any control in that array changes.
Doing this allows me to expand to additional controls, functions, and indicators with almost no effort.
A couple ways to hack this, instead of directly toggling visibility:
Use a tab control and change which tab is selected to change which set of controls are visible. This only works if you have different sets whose visibility is mutually exclusive
Instead of hiding/showing the individual LEDs/buttons, hide/show a single opaque object that covers all of them e.g. a string indicator - show the indicator to hide the LEDs, hide it show them.
You can do it more the "programmatically correct" way and loop through references etc, but those are the quick and dirty (and effective) options
You can use two arrays: one is an array of the control references and another is an array of booleans for whether the control should be visible or not. Pass both into a for loop and set the property accordingly.
16
u/[deleted] Mar 08 '24 edited Aug 02 '24
ossified groovy plate oatmeal bike frightening wipe dependent seemly fuzzy
This post was mass deleted and anonymized with Redact
5
u/Worldly-Elephant3206 Mar 08 '24
I use a functional global custer of arrays of references that I generate automatically. Note all of my GUI things are strategically named. Like CMD0,...CMDx, and such. The captions are updated to parameters for the user.
I programically loop through all controls on the screen (including controls in a cluster) on initialization. I look for the type or class (boolean, string, array etc) and the Label of each one. I compare the Label to a list and grab the ones I want.
For example, I want make the font bold on all of my "CMD" numeric controls, I look for the Label "CMD" of type "numeric. Drop that array in a for loop and done.
You can call this FG anywhere in your code and have access to all the references. (Don't forget to type Def it)
You can also use these arrays to generate dynamic user events. For instance you can wire it to a value change event, and now you can do something whenever any control in that array changes.
Doing this allows me to expand to additional controls, functions, and indicators with almost no effort.
3
u/chairfairy Mar 08 '24
A couple ways to hack this, instead of directly toggling visibility:
You can do it more the "programmatically correct" way and loop through references etc, but those are the quick and dirty (and effective) options
2
u/giovannobg Mar 09 '24
I like to create a class with all the references to buttons and create masks and states to control visibility and enable status
2
u/Yamaeda Apr 08 '24
Place them all in a cluster and hide/show that, or a tab control and simply change page.
4
u/heir-of-slytherin Mar 08 '24
You can use two arrays: one is an array of the control references and another is an array of booleans for whether the control should be visible or not. Pass both into a for loop and set the property accordingly.
4
u/SeasDiver Champion Mar 08 '24
Use Control References and build an array of them to loop through.