Notifications
Clear all

[Closed] Appending to dropdownlist.items

Hi everyone,

I am trying to append to the items parameter of a dropdownlist. My problem is that once added the dropdownlist does not display this new item in its list.


   rollout ddlTrouble_gui "Dropdownlist example"
   (
   	dropdownlist ddl_example "List:" items:#("Facer")
   	button btn_press "Press Me"
   	
   	on btn_press pressed do
   	(
   		append ddl_example.items "FX"
   		print ddl_example.items
   	)
   )
   
   createDialog ddlTrouble_gui
   

This code is an example of what I am experiencing.

When the button is pressed it appends the string “FX” to the items parameter of the dropdowlist ddl_example and then immediately prints the contents of ddl_example.items in the listener.

You can see in the listener that it has been successfully added to the dropdownlist, but when you expand the dropdownlist there is still only one item.

Is there a refresh command for rollouts or UI items that I should be using?

Thanks,
Mathieson

4 Replies

Hi.

This should work:

on btn_press pressed do
(
	items = ddl_example.items
	append items "FX"
	ddl_example.items = items
	print ddl_example.items
)

Greets.

Also see MAXScript Reference > Frequently Asked Questions > Practical Questions > Working with Scripted UI > How do I update the items in a dropdownList or listBox? [left](nope, you are not the first to ask ;))

In the case of append, you would have to assign the result of append to the items array:

   rollout ddlTrouble_gui "Dropdownlist example"
   (
	   dropdownlist ddl_example "List:" items:#("Facer")
	   button btn_press "Press Me"
	   
	   on btn_press pressed do
	   (
		   ddl_example.items = append ddl_example.items "FX"
		   print ddl_example.items
	   )
   )
   
   createDialog ddlTrouble_gui

[/left]

Thanks Bobo. Thanks HalfVector.

I thought it would be in the reference, I was just looking in the wrong places.

Thanks again guys, I really appreciate it.

1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

A link from the dropdownlist topic to the FAQ topic would have been nice.
Somebody needs to get slapped… Oh wait!