ScriptSpot

Forum topic · General Scripting

multilistbox, scene objects

By sdds · 2016-02-24

Description

hi all im having trouble selecting objects with a multilistbox. ive manged to get the names of selected items as strings. what i want is the actual selected listbox objects to be added to an array. Any help would be great, a standard listbox is much easier lol

arr = cameras as array
listed = sort(for i in arr collect i.name)

rollout test "" width:162 height:243
(
multilistbox mylistbox "ListBox" pos:[19,25] width:122 height:9 items: listed

button del "del"
on del pressed do
(

--sets items names from bitarray to string array
selNames = for i in mylistbox.selection collect mylistbox.items[i]
print selNames
)
)

createdialog test

Comments (2)

.

miauu · 2016-02-24



	

	rollout test "" width:162 height:243
	(
		local camArr = cameras as array
		local camNamesArr = for n in camArr collect n.name 
			
		multilistbox mylistbox "ListBox" pos:[19,25] width:122 height:9 items:camNamesArr

		button del "del"
		
		on del pressed do
		(
			selIdx = (mylistbox.selection as array)[1]
			--	"delete the object from the scene"
			delete camArr[selIdx]
			--	"deete the object from the array"
			deleteItem camArr selIdx
			--	"delete its name from the list"
			deleteItem camNamesArr selIdx
			--	"update the names in the list"
			mylistbox.items = camNamesArr
		)
	)

	createdialog test