Update Button Text

Hello everyone!
In the example below, I have a button that opens the Material/Map Browser dialog and the text of the button takes the name of the texture map(fron Help MaxScript).
The button "Close" destroy the rollout. All ok.

Now, when I reopen the dialog, the mapbutton text is again "None". It is normal because the label of the button is "None" but, how to update a text of a button with the name of the texture map that I have chosen?

I created a script where added the Texture map of a light($.projectorMap), but every time I reopen the panel, the button no longer has the name of the map (see in Advanced Effect of the light).

------------------------------------------------------------------------------------
rollout test "Test Txt"
(
button cr "Create Light"
mapbutton a "None" map:undefined
button b "Close"

on cr pressed do
(
lig=TargetDirectionallight pos:[200,0,0] isSelected:on target:(Targetobject transform:(matrix3 \ [1,0,0] [0,1,0] [0,0,1] [0,0,0]))
)
on a picked texmap do
(
lig.projectorMap = texmap
a.text=classof texmap as string
)

on b pressed do destroydialog test
)
createdialog test
------------------------------------------------------------------------------------

Can someone help me?
Thanks in advance

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anubis's picture

Its important how you wish

Its important how you wish to store your object into the rollout (by name is an easy way) and to use "open" handle to backup what you need to the rollout.

rollout test "Test Txt"
(
	local lig -- important !
	button cr "Create Light"
	mapbutton a "None" map:undefined
	button b "Close" 
 
	on cr pressed do
	(
		lig=TargetDirectionallight pos:[200,0,0] isSelected:on \
			target:(Targetobject transform:(matrix3 1)) \
				name:"Example" -- important !
	)
	on a picked texmap do
	(
		lig.projectorMap = texmap
		a.text=classof texmap as string
	)
	on b pressed do (destroyDialog test)
 
	on test open do -- important !
	(
		lig = getNodeByName "Example"
		if isValidNode lig do
		(
			if superClassOf lig == light do
			(
				if lig.projectorMap != undefined do
					a.text = (classOf lig.projectorMap) as string
			)
		)
	)
)
createDialog test

my recent MAXScripts RSS (archive here)

Michele71's picture

Anubis, I do not know how to

Anubis, I do not know how to thank you. I have to go around the world in 3 days? :) :)
Are days that I want a solution that I found. But you, open my mind! I thought everything except your solution.. still have a long way to go with MaxScript.

Thank you for your kind reply!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.