
Enable and populate popup menu programatically?

bendrinksalotofcoffee
I'm building a panel where I use one popup menu to select from a series of experiments, each of which has either 1, 2, or 3 replicates. I want to enable and populate another popup menu with the replicate number. All the popup menus are pre-created when the panel is initiated, and the replicate popup is disabled until an experiment is chosen.
How do I manipulate an already-existing control? I can't find anything about this anywhere!
Just call PopupMenu again, preferably with the win= keyword attached to target the right panel, then append the option you want to modify (I guess value= in this case). This works the same with all controls. Note that you must use the same name of the control, otherwise you create a new popup control.
October 29, 2024 at 08:55 pm - Permalink
In reply to Just call PopupMenu again,… by chozo
Brilliant, thank you.
Edit: maybe you can help me with this problem. I've got this in a function:
and the function makeValueString:
It doesn't work. It compiles, and I've verified that the makeValueString() function is returning what I want, but the popup contains "_none_".
October 29, 2024 at 08:58 pm - Permalink
The usage of # requires a string in a specific style. In particular, you need to add a literal quote character:
A few other notes:
October 30, 2024 at 01:31 am - Permalink
It's possible that instead of the `popValue` keyword, perhaps you want `mode`, which selects the item number to show. If you have a menu with value="1;2;3;", then setting `mode=1` selects the first item, which by coincidence happens to match the item number.
Frankly, the `popValue` keyword has a very specific and obscure purpose. It is generated in recreation macros so that if conditions prevent the generation of a menu value list that includes the selected item, the menu will still look like it did when you saved the experiment. Personally, I would prefer that the menu actually reflect current conditions. I would get rid of the `popValue` keyword if I could, but there are thousands of recreation macros that would stop working.
October 30, 2024 at 10:06 am - Permalink