View Full Version : How to add a new button by clicking an existed button
02-11-2009, 02:36 AM
Hello everyone! I have a question:
I want to create a button that you can click it and then add a new button just like the Multi/Sub-Object material .
I donít know how to make it.
Anyone could help me?
02-11-2009, 08:06 AM
you would have to create a dynamic UI... you can either...
A. Use maxscript UI elements
in which case you'll have to either...
A.a Build the rollout, as a string, yourself - then evaluate that string and open that new rollout to update your UI
A.b Use the RolloutCreator (see help file) to help you build the rollout and open that new rollout to update your UI
fn addAnotherButton = (
roll_buttons_count += 1
counter = roll_buttons_count as string
roll_buttons += "button btn_" + counter + " \"Button " + counter + "\"\n"
roll_header = "
rollout roll_test \"test\" (
button btn_test \"test\"
on btn_test pressed do (
roll_footer = "
label lbl_test \"test\"
roll_buttons = ""
roll_buttons_count = 0
fn buildRollout = (
execute (roll_header + roll_buttons + roll_footer)
B. Use .NET
.NET gives you the advantage of adding buttons to a UI without having to close/re-open that UI. The disadvantage is that these buttons -have- to be .NET buttons, within a .NET form or other .NET-controls-capable .NET control (e.g. a tab), onto which you cannot place any MaxScript controls.
rollout roll_test "test" width:220 height:220 (
dotNetControl dnc_panel "Windows.Forms.Panel" width:200 height:200
local numButtons = 0
fn clickFunc sender args = (
numButtons += 1
local newButton = (dotNetObject "Windows.Forms.Button")
newButton.text = "Button " + numButtons as string
newButton.top = 24 * numButtons
on roll_test open do (
dnc_panel.autoScroll = true -- in case of many buttons
local firstButton = (dotNetObject "Windows.Forms.Button")
firstButton.text = "Hello"
dotNet.addEventHandler firstButton "click" clickfunc
02-12-2009, 12:35 PM
You're so kindhearted.
I'm reading your MAXScript and trying to get it.
Thanks a lot!
02-12-2009, 12:35 PM
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.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.