Below I have a listbox that works exactly the way I want it to. Allowing users to move objects up and down, remove, add and clear. However some of those features to not work when changed over to a multilist box. Which is what I need because it allows for multiple objects to be selected. I just cant figure out how to get the moving up and down to work as well as the remove with multilist.
Here is what i have that works for listbox.
(
local AnimObjs = #()
rollout rlD ""
(
ListBox lbxAnimatedObjects "Animated Objects" pos:[10,7] width:120 height:12
button btnAddAnimObj "+" pos:[10,185] width:24 height:24
button btnRemoveAnimObjs "-" pos:[34,185] width:24 height:24
button btnClearAnimObjs "X" pos:[58,185] width:24 height:24
button btnMoveUpAnimObj"^" pos:[82,185] width:24 height:24
button btnMoveDownAnimObj "v" pos:[106,185] width:24 height:24
on btnAddAnimObj pressed do -- Add Objects
(
userSel = getCurrentSelection()
if userSel.count >= 1 do
(
for o in userSel do (appendIfUnique AnimObjs o)
lbxAnimatedObjects.items = for i in AnimObjs collect i.name -- update list with array
)
)
on btnRemoveAnimObjs pressed do -- Removes Object fromt list
(
local currSel = lbxAnimatedObjects.selection
for i = lbxAnimatedObjects.items.count to 1 by -1 where currSel[i] do (deleteItem AnimObjs i)
lbxAnimatedObjects.items = for i in AnimObjs collect i.name -- update list with array
)
on btnMoveUpAnimObj pressed do
(
local itm = lbxAnimatedObjects.selection
if itm > 1 do
(
swap lbxAnimatedObjects.items[itm] lbxAnimatedObjects.items[itm-1]
lbxAnimatedObjects.items = lbxAnimatedObjects.items
swap AnimObjs[itm] AnimObjs[itm-1]
lbxAnimatedObjects.selection -= 1
)
)
on btnMoveDownAnimObj pressed do
(
local itm = lbxAnimatedObjects.selection
if itm < lbxAnimatedObjects.items.count do
(
swap lbxAnimatedObjects.items[itm] lbxAnimatedObjects.items[itm+1]
lbxAnimatedObjects.items = lbxAnimatedObjects.items
swap AnimObjs[itm] AnimObjs[itm+1]
lbxAnimatedObjects.selection += 1
)
print AnimObjs
)
on btnClearAnimObjs pressed do lbxAnimatedObjects.items = (AnimObjs=#()) -- Clear List
)
createDialog rlD 140 225
)
By JokerMartini · 2011-05-18
barigazy · 2012-07-06
Graph · 2011-05-19