PDA

View Full Version : Appending to dropdownlist.items


Mathieson
10-23-2006, 05:00 PM
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

HalfVector
10-23-2006, 05:06 PM
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.

Bobo
10-23-2006, 05:16 PM
Also see MAXScript Reference > Frequently Asked Questions > Practical Questions > Working with Scripted UI > How do I update the items in a dropdownList or listBox? (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

Mathieson
10-23-2006, 05:31 PM
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.

Bobo
10-23-2006, 05:41 PM
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.

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

CGTalk Moderation
10-23-2006, 05:41 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.