MaxScript: Dialog process messages

MaxScript: Dialog process messages

istan
Advisor Advisor
1,743 Views
5 Replies
Message 1 of 6

MaxScript: Dialog process messages

istan
Advisor
Advisor

When I create a rollout and a function runs a longer script, how can I enable the dialog for letting the user press an "abort" button? In Windows there's a processmessage, but how is this done in MaxScript? I know, I could query the escape button, but all of my users unlearnt how to use a keyboard..

0 Likes
Accepted solutions (1)
1,744 Views
5 Replies
Replies (5)
Message 2 of 6

denisT.MaxDoctor
Advisor
Advisor

i would run the "long process" with a timer, and added inside the process repeatable check of some UI control for ON/OFF state 

0 Likes
Message 3 of 6

istan
Advisor
Advisor

Since a "Timer" message is also just a regular dialog message, I'm not sure if it's even processed..

I'll test.

0 Likes
Message 4 of 6

MartinBeh
Advisor
Advisor
Accepted solution

Is

 

windows.processPostedMessages()

 

what you are looking for?

Martin B   EESignature
→ please 'Like' posts that are helpful; if a post answers your question please click the "Accept Solution" button.
Message 5 of 6

denisT.MaxDoctor
Advisor
Advisor

my first reaction was - Yes! how could i forget about windows.processPostedMessages()

 

and have looked in my archive... here is what i found with my own comments: 

 

try (destroydialog progressRol) catch()
rollout progressRol "Progress..." width:200
(
	progressbar pb width:186 pos:[8,4]
	checkbutton start "Start" width:186 pos:[8,24]
	on start changed state do if state do 
	(
		while not keyboard.escpressed and start.state do
		(
			pb.value += 5
 			sleep 0.5
			windows.processPostedMessages()
		)
		
		pb.value = 0
		start.state = off
	)
)
createdialog progressRol

 

run this script. by pressing "Start" button you can turn ON/OFF the 'process'. everything works and looks OK while we not press "Close" window button.

 

if you do it during the running 'process' you will get 'lugging' for all your operations (try to edit code in the editor for example).

so you have to understand that the using of processPostedMessages is not safe in some situations 

0 Likes
Message 6 of 6

istan
Advisor
Advisor

Hi Martin,

this is exactly what I was looking for.

Thank you!

0 Likes