Changing Caption on a Button in Script during Flow

Changing Caption on a Button in Script during Flow

admin
Participant Participant
741 Views
4 Replies
Message 1 of 5

Changing Caption on a Button in Script during Flow

admin
Participant
Participant

Hey folks.

I have a button "MyButtonName" pos....etc

I want to change the Button Caption on different actions like this:

1. Button Caption is: "Select xy"
2. after action is done Button Caption is "DONE"

This is already Working!
Now i want to set it back to the Start means after a short sleep i want to have it back to Caption in 1 ("select xy")

In Unity i did such things with switch cases but in Maxscript i am lost.

How can i set a kind of procedural Caption Placeholder that carries out the Caption name into the button?

THX and Regards

0 Likes
742 Views
4 Replies
Replies (4)
Message 2 of 5

denisT.MaxDoctor
Advisor
Advisor

what button do you talk about? Rollout button? Macro button? ...

0 Likes
Message 3 of 5

denisT.MaxDoctor
Advisor
Advisor

for Rollout UI controls the most common solution is to use a Timer control:

try(destroydialog rol) catch ()
rollout rol "RO:3DE86D88" width:191
(
	timer job_tm interval:2000 active:off
	button select_bt "Select" width:160
	checkbutton process_bt "Process" highlightcolor:brown width:160 offset:[0,8]
	
	local recent_job = undefined
	on job_tm tick do
	(
		if recent_job != undefined do recent_job()

		job_tm.active = off
	)
	
	on select_bt pressed do 
	(
		select_bt.text = "DONE"
		recent_job = (fn _ = (select_bt.text = "Select"))
		job_tm.active = on
	)

	on process_bt changed state do 
	(
		if state then
		(
			process_bt.text = "Processing..."
			recent_job = (fn _ = (process_bt.changed off))
		)
		else
		(
			job_tm.active = off
			process_bt.state = off
			process_bt.text = "Process" 
		)
		job_tm.active = on			
	)
	
	on rol open do
	(
	)
)
createdialog rol

 

0 Likes
Message 4 of 5

denisT.MaxDoctor
Advisor
Advisor

another solution is to use scene notifications and node events... that's another story

0 Likes
Message 5 of 5

admin
Participant
Participant

Hey Pros, @denisT.MaxDoctor 

i set up a small example to train myself with this noob logic

see attached script example 

 this is just for learning purposes, it might be a dumb approach but
 let me just solve it to understand the tracking in this case of a simple string value!
 
I tried the fn inside and outisde the rollout but i cant keep track of the string/caption value
 
 
 
 try (closeRolloutFloater theNewFloater) catch()
 
btnTxt = "Default Name"
MyState = 1
 
 rollout ButtonTest1 "Grin Control"
 
   (
   --fn changeMe1=
--(
--btnTxt = "New Name"
--)
   
button 'btn6' btnTxt pos:[10,20] width:100 height:50 enabled:true align:#center
   
   on button pressed do
   (
   
   --keeo track of the state i am in
   --set the name in a sep function and use the function in
   --the desired state i am in
   
   MyState.count == 1
   
   if MyState.count== 1 then ChangeMe1() else
   (
   if MyState.count== then CHangme2() else
   (
   if MyState.count == 3 do changeMe3()
   )
   )
   )
   )
rollout ButtonTest2 "Grin Control"
   (
 
   )
   -fn changeMe1=
(
btnTxt = "New Name"
)
 
fn changeMe1=
(
btnTxt = "New Name2"
)
 
fn changeMe1=
(
btnTxt = "New Name3"
)
   
   
   
   
   
   
   
   theNewFloater = newRolloutFloater "Grinning" 300 220
   addRollout ButtonTest1 theNewFloater
   addRollout ButtonTest2 theNewFloater
0 Likes