[Closed] Creating a new listbox
Hi,
Is there a was we can create a new listbox upon pressing a button. I mean say when we specify newscript() it opens a new maxscript page, similarly I need to open up a new listbox on the click of a button. Also this list box should contain data from another file (all the objects from another max file lsited here), which I need to pass on to my ongoing script.
I hope I was clear with my query,
Thanks,
Vikram
The best way to do this is to pre-define a rollout with a listbox and create a modal dialog when you press the button. Add an OK and a Cancel button to close that dialog. In the ON OPEN handler of the rollout, add the code to populate the listbox. In the handler of the OK button, pass the selection data back to the calling script (assuming your calling script has its rollout defined as global, passing data back should be easy).
If you want the listbox to appear in the same dialog as your button, you would have to rebuild the whole rollout, and it would be rather tricky.
Hi Bobo,
Thanks for the help, but I couldnt figure it out yet. I’m pasting my code. The error occurs when you choose “Get from another max file” in the radiobutton and press the “Pick Master Object”. When you select another maxfile, what I intend is that the new listbox should contain the list of objects in that particular selected max file.
Thanks,
Vikram
Warning : My max hung a few times while trying this!!!
global object_master = #()
global object_target = #()
global morphCount = 0
global flname = ""
global obj_names = #()
rollout openobjectlist "Select Target"
(
listbox lbx_objects "Morph Targets:"
)
rollout morphcpy "Transfer Morph Animation"
(
radiobuttons rad_master "Master object in:" labels:#("Current Max File", "Get from another file")
button btn_master "Pick Master Object" visible:false pos:[66,42] width:150
pickButton pckbtn_master "Pick Master Object" pos:[66,42] width:150
radiobuttons rad_target "Transfer animation of:" labels:#("All Targets ", "Specific Target ")
pickButton btn_target "Pick Target Object" width:150
label lb1 "--------------------------------------------------------------"
label lb2 "Transfer animation of All Targets will not work correctly"
label lb3 "if there is an empty slot inbetween in the Morpher modifier"
label lb4 "--------------------------------------------------------------"
label lb5 "Transfer animation of All Targets is by position"
label lb6 "of morph target and not it's name"
label lb7 "--------------------------------------------------------------"
button btn_clear "Clear Data" width:150
label lb8 "Script by Vikram Shingrani"
hyperLink gmail "email : [email="http://forums.cgsociety.org/vshingrani@gmail.com"]vshingrani@gmail.com[/email]" color:(color 0 0 255) address:"[email="http://forums.cgsociety.org/vshingrani@gmail.com"]mailto:vshingrani@gmail.com[/email]" align:#center
-- listbox lbx_objects "Morph Targets:"
on rad_master changed sel do
(
case sel of
(
1: (
btn_master.visible = false
pckbtn_master.visible = true
)
2: (
btn_master.visible = true
pckbtn_master.visible = false
)
)
)
on pckbtn_master picked obj do
(
clearselection()
if rad_master.state == 1 then
(
if obj != undefined do
(
pckbtn_master.text = obj.name
select obj
)
object_master = (getCurrentSelection())[1]
)
)
on btn_master pressed do
(
flname = getopenFileName caption:"Load Morph File"
if (flname != undefined) then
(
createdialog openobjectlist width:280
obj_names = getmaxfileobjectnames flname
lbx_objects.items = obj_names
)
)
on btn_target picked obj do
(
if pckbtn_master.text == "Pick Master Object"
then messagebox "Please pick the Master object first"
else
(
if obj != undefined do
(
btn_target.text = obj.name
select obj
)
object_target = (getCurrentSelection())[1]
morphCount = 1
while (WM3_MC_HasData object_master.morpher morphCount) == true do
(
morphCount += 1
)
morphCount -= 1
for i = 1 to morphCount do
try
(
(
if object_master.morpher[i].controller.keyable == true
then
(
object_target.morpher[i].controller = copy object_master.morpher[i].controller
)
)
)
catch()
)
)
on btn_clear pressed do
(
if (pckbtn_master.text == "Pick Master Object")
then
(
messagebox "Data already clear"
)
else
(
pckbtn_master.text = "Pick Master Object"
btn_target.text = "Pick target Object"
object_master = #()
object_target = #()
morphCount = 0
)
)
)
createdialog morphcpy width:280