HumanUI: ...but I DO need to drive the creation of elements with the results of a value listener...?

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:

  • If they choose the latter, I want them to select an hour of year using 3 sliders (month, day, hour):

I’ve marked the connection that causes the freezing behaviour and the warning in the AddElements component:

  1. 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? (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.

Thanks @andheum,

Spot on, it works: (14.3 KB)

Is there a way to still have all that in an expander? The way I’m doing it here doesn’t work: (17.2 KB)

“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:

I think this is because I’m duplicating the “Selection method” dropdown (it is present in both expanders).

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.