Notifications
Clear all

[Closed] Possible to make listboxes in listboxes?

Is it possible to make list boxes stack ontop of each other in subrollouts? for example using the code below, if I press add bone more then once then I want another listbox to show up below the one just created. At the moment it seems that only 1 can be made and if any more are added they just disappear.

TEST_Array=#("test1","test2","test3","test4")
clearlistener()

rollout BoneHandler "BONE LINKER" width:696 height:440(
	dropdownList BonesInScene "" pos:[8,8] width:568 height:21 items:(TEST_Array)
	subRollout BonesToFile "" pos:[8,40] width:680 height:360
	button AddBNS "Add Bone" pos:[584,8] width:104 height:24
	button LOADAET "Load FILE" pos:[120,408] width:104 height:24
	button LOADCHA "Load Cache" pos:[472,408] width:104 height:24
	button SAVCHA "Save Cache" pos:[584,408] width:104 height:24
	button LOADSCE "Load Scene" pos:[8,408] width:104 height:24
	on AddBNS pressed do(
		if BonesInScene.selection == 0 then(
			messagebox "No Bones Selected"
		)
		else(
			rollout BNS BonesInScene.items[BonesInScene.selection] width:664 height:232(
				dropdownList obj pos:[8,8] width:536 height:21
				listbox BDATA BonesInScene.items[BonesInScene.selection] pos:[8,32] width:536 height:13
				button ADDOBJ "Add Object" pos:[552,8] width:104 height:24
				button REMOBJ "Remove Object" pos:[552,40] width:104 height:24
				button MOBJUP "Move Object Up" pos:[552,72] width:104 height:24
				button MOBJDWN "Move Object Down" pos:[552,104] width:104 height:24
				button MBNSUP "Move Bone Up" pos:[552,136] width:104 height:24
				button MBNSDWN "Move Bone Down" pos:[552,168] width:104 height:24
				button RBNS "Remove Bone" pos:[552,200] width:104 height:24
				on RBNS pressed do(
					BonesInScene.items= append BonesInScene.items (BDATA.text)
					removesubrollout BoneHandler.BonesToFile BNS
				)
			)
			AddSubRollout BoneHandler.BonesToFile BNS
			BonesInScene.items=deleteitem BonesInScene.items BonesInScene.selection
			BonesInScene.selection = 1
		)
	)
)
createDialog BoneHandler
13 Replies

I’ve never done this before, so there might be better solutions, but one way to do it could be creating the rollouts dynamically, as a fixed rollout will hold the same instance thus not allowing you to add it more than once.

From your previous code, here is one example:

(	
 	/* Create some test items for the list and
 	clear the global rollouts variables if any
 	just for this example.*/
 	items= for j = 1 to 10 collect
 	(
 		itemname = "test_" + (j as string)
 		execute (itemname + "=undefined")
 		itemname
 	)
 	
 	rollout BoneHandler "test" width:640 height:608
 	(
 		
 		dropdownList BonesInScene "" pos:[8,8] width:528 height:21 items:items
 		subRollout BonesToFile pos:[8,32] width:529 height:568
 		button AddB "Add" pos:[544,8] width:88 height:24
 		button RemoveB "Remove" pos:[544,40] width:88 height:24
 		button Mup "Move Up" pos:[544,72] width:88 height:24
 		button Mdwn "Move Down" pos:[544,104] width:88 height:24
 		
 		fn CreateRollout name =
 		(
 			/* If this rollout variable is undefined then create and
 			add it to the subrollout control */
 			if (execute name) == undefined do
 			(
 				str = "rollout " + name + "\"" + name + "\"" + "height:56"
 				str += "("
 				str += "listBox lbx1 pos:[8,8] width:448 height:1"
 				str += ")"
 				AddSubRollout BonesToFile (execute str)
 			)
 		)
 		
 		on AddB pressed do
 		(
 			CreateRollout (BonesInScene.items[BonesInScene.selection] as string)
 		)
 		
 		on RemoveB pressed do(
 			if (BonesToFile.rollouts.count>0) do
 			(
 				/* Just as an example, remove the last rollout in the subrollout
 				control and set its global variable to undefined, so it can be added
 				later again */
 				theRollout = BonesToFile.rollouts[BonesToFile.rollouts.count]
 				removesubrollout BonesToFile theRollout
 				execute (theRollout.name + "=undefined")
 			)
 		)
 		
 	)
 	
 	createDialog BoneHandler
 	clearlistener()
 
 )

If you need to add more complex rollouts, perhaps you could also use the build in RolloutCreator.
Again, it might not be the best or more elegant solution, but it appears to work.

“listboxes in listboxes” is a treeview

Thanks Polytools you just showed me a way I haven’t realized could be done and I love it extremely useful for what im trying to do.

denisT with my current scripting experience I cannot make treeviews. Im getting allot better at maxscript since I started it as a hobby back in October but after looking everywhere online for tips on the matter I just feel like im not ready for it yet.

sry for double post.

I actually have ran into a snag. Using this method how would I be able to use “on pressed % do” ? if I make buttons inside of the new subrollouts they aren’t registered as buttons cause they are in code as strings.

If you are planning to use complex subrollouts, perhaps it would be good to have a function or a set of functions to properly build the string to be executed, as concatenating the strings manually is a little painful.

Below is one example of a dynamic subrollout with a functional button:

(	
 	 /* Create some test items for the list and
 	 clear the global rollouts variables if any
 	 just for this example.*/
 	 items= for j = 1 to 10 collect
 	 (
 		 itemname = "test_" + (j as string)
 		 execute (itemname + "=undefined")
 		 itemname
 	 )
 	 
 	 rollout BoneHandler "test" width:640 height:608
 	 (
 		 
 		 dropdownList BonesInScene "" pos:[8,8] width:528 height:21 items:items
 		 subRollout BonesToFile pos:[8,32] width:529 height:568
 		 button AddB "Add" pos:[544,8] width:88 height:24
 		 button RemoveB "Remove" pos:[544,40] width:88 height:24
 		 button Mup "Move Up" pos:[544,72] width:88 height:24
 		 button Mdwn "Move Down" pos:[544,104] width:88 height:24
 		 
 		 fn CreateRollout name =
 		 (
 			 /* If this rollout variable is undefined then create and
 			 add it to the subrollout control. Additionally this
 			Subrollout has now a functional Button.*/
 			 if (execute name) == undefined do
 			 (
 				 str = "rollout " + name + "\"" + name + "\"" + "height:56"
 				 str += "(
"
 				 str += "button bt_1 \"TEST\"pos:[8,8] width:80 height:30
"
 				str += "on bt_1 pressed do messagebox \"Button Pressed " + name + "\""
 				 str += "
)"
 				 AddSubRollout BonesToFile (execute str)
 			 )
 		 )
 		 
 		 on AddB pressed do
 		 (
 			 CreateRollout (BonesInScene.items[BonesInScene.selection] as string)
 		 )
 		 
 		 on RemoveB pressed do(
 			 if (BonesToFile.rollouts.count>0) do
 			 (
 				 /* Just as an example, remove the last rollout in the subrollout
 				 control and set its global variable to undefined, so it can be added
 				 later again */
 				 theRollout = BonesToFile.rollouts[BonesToFile.rollouts.count]
 				 removesubrollout BonesToFile theRollout
 				 execute (theRollout.name + "=undefined")
 			 )
 		 )
 		 
 	 )
 	 
 	 createDialog BoneHandler
 	 clearlistener()
  
  )

I haven’t used the RolloutCreator neither I’ve looked at its code until now. I was actually expecting a much longer code, but it is rather simple and short.

Perhaps with a minor modification you can make it fully functional for your pourposes?

The route for the source .ms file is mentioned at the beginning of the link.

i tried to use rolloutcreater. and i have to say ‘no’. it doesn’t generally work.

you can see that ‘on-fly’ rollout turns out to be much complicated than treeview. i suggest to go more native way than try to use tricks. there are a lot samples on this forum how to deal with a treeview

if you tell me what you really want to implement i can easily give you a snippet

Thanks poly that will definitely be useful in future projects. DenisT I am always willing to learn something new. It could be possible that I was not searching correctly online for treeviews in maxscript so sure let me see a sample of code and ill try to practice on it.

1 Reply
(@troopermanaic)
Joined: 11 months ago

Posts: 0

Im sorry if this is a noob question I didn’t want to ask this but I see nothing there that can add child nodes. I just need to know how do you add a node inside of a node?
Here is a sample of what im working with,

try(destroydialog subAnimsInspector) catch()
clearlistener()
rollout subAnimsInspector "Find SubAnims with denisT" width:256 height:552(
	dotNetControl tv "TreeView" pos:[4,8] width:244 height:488
	button search_bt "Add" pos:[8,504] width:240 height:21
	button btn2 "Sub" pos:[8,528] width:240 height:21
	on search_bt pressed do(
		newNode=tv.nodes.add "Test1"
		print newNode
	)
	on btn2 pressed do(
		newNode=tv.nodes.add "Test2"
	)
)
createdialog subAnimsInspector
Page 1 / 2