PDA

View Full Version : dynamicly update a rollout when adding stuff in a listbox...


CapitanRed
04-12-2008, 02:20 PM
hi, I'm trying to dynamicly update a rollout when adding stuff in a listbox. when i add a node to the listbox, i'd like to set three checkboxes beside it.
Is there a way for doing this?

labbejason
04-12-2008, 06:25 PM
Your description is pretty vague of what you want to accomplish, but here's something I whipped together. Paste it in a new script and give it a try. Hopefully it's what you are after.


(

rollout myRollout "Example"

(

listBox nodeList "Nodes"

button addNodes "Add selection to list" width:170 height:15

button clearList "Clear List" width:170 height:15

checkBox checkA "A" across:3 enabled:false align:#left

checkBox checkB "B" enabled:false align:#center

checkBox checkC "C" enabled:false align:#right



fn setCheckState = -- When this function is called, it will see if there are any items in the listBox, which will set the state of the checkBoxes

(

if nodeList.items.count > 0 then

(

checkA.state = true; checkA.enabled = true

checkB.state = true; checkB.enabled = true

checkC.state = true; checkC.enabled = true

)

else

(

checkA.state = false; checkA.enabled = false

checkB.state = false; checkB.enabled = false

checkC.state = false; checkC.enabled = false

)

)



on addNodes pressed do

(

nodeList.items = for o in $selection collect o.name

setCheckState()

)



on clearList pressed do

(

nodeList.items = #()

setCheckState()

)

)

createDialog myRollout 200 230

)

CapitanRed
04-12-2008, 06:37 PM
hey labbejason

thanx for the reply. well it's not what i was after. I'm sorry that i wasn't explaining enough.

what i want is to have a list box in which i can load in as many nodes i want. and it should have a checkbox on the right for every node i load in.
so if i load in 5 nodes, then i have 5 checkboxes on the right, if i add then 3 nodes to these 5 nodes, i'll have 8 checkboxes on the right and so on...
allways having as many checkboxes as there are nodes in the list.

CapitanRed
04-12-2008, 07:02 PM
I tought about something like this. when you remove the /* and */ the script dosent work anymore... :(

myNodesArr = #()
fn selectNodes = (

myNodes = selectbyName()

for i in myNodes do(

append myNodesArr i.name

)

removeRollout rollout1 myfloater

rollout rollout1 "rollout1"(

listbox myListBox "load some nodes" width:100 items:myNodesArr

button add "add"



/*



for num in myNodesArr do(

checkbox myCheckbox[num] num

)

*/

on add pressed do selectNodes()

)

addRollout rollout1 myFloater

)









rollout rollout1 "rollout1"(

listbox myListBox "load some nodes" width:100

button add "add"



on add pressed do selectNodes()

)

myFloater = newRolloutFloater "myfloater" 200 300

addRollout rollout1 myFloater

Bobo
04-12-2008, 08:33 PM
hey labbejason

thanx for the reply. well it's not what i was after. I'm sorry that i wasn't explaining enough.

what i want is to have a list box in which i can load in as many nodes i want. and it should have a checkbox on the right for every node i load in.
so if i load in 5 nodes, then i have 5 checkboxes on the right, if i add then 3 nodes to these 5 nodes, i'll have 8 checkboxes on the right and so on...
allways having as many checkboxes as there are nodes in the list.

Do you mean "CHECKBOXES INSIDE OF LISTBOX"???!?
As you probably know, a listbox cannot contain anything else than strings.
(If you didn't know, then, well, now you do)

You have several options here:

*Simulate the "checkbox" yourself by using some form of checkmark or + sign inside the string with the node name. Use the double-click handler to switch the state of the node.

*Use a ListView which can have a checkbox in each line TO THE LEFT of the first column. See the ActiveX and DotNet ListView topics in the MAXScript Reference. Note that in Max 9 and higher, you should be using the DotNet flavour - there is a dedicated topic on converting the ActiveX examples into DotNet examples including a ListView-based "outlook" tool that lists all selected nodes with some properties.

See "Converting ActiveX ListView Control to DotNet ListView Control" and the corresponding "How To ... Develop a Selected Objects Inspector using ListView ActiveX Control - Part One" and "Part Two" - the latter uses checkboxes.

*You could add a checkbox OUTSIDE of the list and populate it with the correct state depending on the listbox's selection. The list could still show the state in some way, but in order to change it, you would select an item on the list and change the checkbox that is below the list which will reflect its actual state.

If I missed again what you want, please provide a mockup of the UI you envision by painting it in Photoshop or something...

labbejason
04-12-2008, 10:39 PM
Ahhhh I think I get what he means now. So let's say you added 3 objects to the list, you want 3 new checkBoxes to be produced beside them? I'm not sure if there's a way to keep adding on new interface elements like that. Maybe you can fake it with automatically having checkboxes beside them, then when you add on objects, have the according checkBoxes become active.

Any ideas Bobo?

CapitanRed
04-14-2008, 09:01 AM
bobo:(If you didn't know, then, well, now you do)

hehe...I did ;)

I think you guys know what i mean. I'll give the listview a try. looks like it is exactly what i was looking for :)
I also tought about predefining the checkboxes, and then enable them. but then when you have more nodes than the listbox is high, and you scroll up and down, the checkboxes will not be beside their node...

thanx for the help...I'll keep you updated if it works :)

CGTalk Moderation
04-14-2008, 09:01 AM
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.