In Human UI, I understand that you aren’t recommended to drive the creation of elements with the results of a value listener, in order to prevent “freezing” behaviour.
However, what if I want to have an element that controls which other elements are displayed in the window?
Example: For a Ladybug script, I want to allow the user some control to define the analysis period. Either, they can select time frames (e.g. summer mornings), or a single hour of year.
If they choose the former, I want them to be able to select seasons and times of day through dropdowns:
I’ve marked the connection that causes the freezing behaviour and the warning in the AddElements component:
In general, it’s not a good idea to drive the creation of
elements with the results of a value listener. Instead, use
the value listener to drive a “Set” operation, from the
UI Output tab, to update the contents of an existing element
in the window. Otherwise, every time something in the window
changes, triggering your value listener, the entire window needs
to be re-generated. This can create the appearance of a “freezing”
behavior. See the example files for more information on the appropriate
configuration of “Create” and “Set” components in Human UI.
…but I can’t think of another way to create the functionality I’m looking for. Any Ideas? unnamed.gh (17.5 KB)
The basic principle is to add both sets of controls, and hide/show them dynamically using Hide/Show Element — then you can have controls that appear/disappear based on different conditions.
“By time frame” should be giving me the other dropdown menus to choose from and not the sliders. When I select the “By point in time” method, nothing is displayed anymore:
Correct - elements can only be in one container - if you add them to another container, they get removed from the first one. You’ll need two separate drop down components.
In general, it’s not a good idea to drive the creation of
elements with the results of a value listener. Instead, use
the value listener to drive a “Set” operation, from the
UI Output tab, to update the contents of an existing element
in the window. Otherwise, every time something in the window
changes, triggering your value listener, the entire window needs
to be re-generated. This can create the appearance of a “freezing”
behavior. See the example files for more information on the appropriate
configuration of “Create” and “Set” components in Human UI.