Scripted simpleObject plugin, Dynamic Dropdown list


How can I link the items of the drop-down control to a parameter?
I have a dropdown that changes the items based on a radio button that is linked to a parameter but every time I deselect the object and select it again, the items are back to default. so I want them as a parameter to make them static.

    parameters pre rollout:presets
        currentPre type:#integer ui:Presets_rdb default:1
        drpdwnItems type:#stringTab
    rollout presets "Presets" (
        radiobuttons Presets_rdb labels:#(...)
        dropdownlist drpdwn_type "Type" items:#("On Top", "Inside")

I tried :
drpdwnItems type:#stringTab ui:drpdwn_type.items
drpdwnItems type:#stringTab ui:drpdwn_type.items.controller
dropdownlist drpdwn_type "Type" items:dropdownlist
No results so far. And I would like to know how I can give the stringtab type parameter default values


it looks like you already have code, but it does not work as you would like. so show your code and someone will help you do things right.


added some of my code and things I’ve tried


The parameter linked to the dropdownlist has to store the current index, so either type #integer or #index.


I don’t want the index. I want to have the items in the drop-down because they are changing constantly.


In that case, something like this:

attributes attrib attribID:#(0x351ac4ab, 0x71ef41c0)
	fn updateItems = 
		local items = for i in this.drpdwnItems where isKindOf i String collect i
		if items.count > 0 do this.presets.drpdwn_type.items = items

	parameters pre rollout:presets
		drpdwnItems type:#stringTab tabSizeVariable:on
		on drpdwnItems tabChanged do if not loading do updateItems()
		on drpdwnItems set val do if not loading do updateItems()

	rollout presets "Presets"
		dropdownList drpdwn_type "Type" items:#("On Top", "Inside")
		on presets open do updateItems()


OK, it’s not working the way I want it to. when I deselect and select the object again it reverts back to default. I didn’t do the attribute thing just changed my original code. was that necessary? but the tabSizeVariable was useful for another error I was getting so thank you.


Attributes was there just to make it a complete piece of code, it can be any plugin container. If you change the drpdwnItems contents, it should work as expected.


I just set the items like:
drpdwn_type.items = #("Oven Side","Oven Top","Shelf","Sink Side","Vitrin","Washer Top");
Is that not considered changing?




<dropdownlist>.items Array
Get/Set the item string array.
Is there another way for changing it?
I’m a little confused. am I supposed to change the controllers items or the parameter?


Read my previous replies - or even better, read throught the code I posted and what the updateItems function does.


yeah sorry, I’m working on three different things here. thanks, it worked perfectly :slightly_smiling_face: