Notifications
Clear all

[Closed] Maxscript : detect complex gui modifications

Hello,

I’m looking for a way to detect modifications in a complex maxscript rollout composed with many controls. I would want to detect if an editext was modified or a checkbox checked,…

Have you already done that ?

I can’t find a way to do this in a generic way. I wouldn’t want to put a function for each controls to detect changes. Any ideas ?

Thanks for advance.

6 Replies

What you need is data-binding. You can do it using Windows Forms. Basically when you have some object (data) and a UI that exposes it, you can subscribe to the INotifyPropertyChanged event that’s implemented by your object, whenever the object is changed.

Light

Thank you for your help, Light!

Unfortunately, I was searching a solution for that in maxscript. I am not familiar with VB or .NET.

I assume there is no easy solution in maxscript, except being a robot and create as much as handler as controls count…

Maybe you could take a look at the rollout creator struct?
I think that it is documented in the maxscript help.

Thanks for the tip Pjanssen. i didn’t know the Rollout creator struct.

I hit another problem if I want to use it : I have some controls already having some “changed” handlers. So I would have to add text to my existing handlers.

As far as I can see in the documentation, the rollout creator is really made to create a rollout from scratch. Adding text to a handlers doesn’t seem to be possible. Therefore it won’t be as generic as I would like. I have to write my specific complex “changed” handlers (a dozen, actually) in the odd rollout creator style, with “@” everywhere. Pretty unreadable and hardly “debuggable”.

Please tell me if I’m wrong. Anyway, thank you again for highlighting this good maxscript feature to me !

 JHN

I have tried and given up on the rollout creator, indeed nice for small UI’s, but in the end it’s just a wrapper that generates and executes strings, so ultimately it’s the same as writing your own strings and executing them, which then allows you to include the code you do want, without the awkward rolloutcreator notations.

Some notes:
-Do you know a rollout has a .controls property with init a array of all controls. Maybe you can monitor the controls over the array and write external functions to keep track of changes. If you don’t need to rebuild the UI constantly maybe that’s a better solution. Keeping track of the state of certain controls under certain conditions.
-Rebuilding UI’s using strings is slow.
-Dotnet has better tools for the job as mentioned.

Hope it helps somewhat,
-Johan

if anyone can solve the scope thing here :argh:


theRollout
clearlistener()
rci = rolloutCreator "myRollout" "My Rollout"
rci.begin()
rci.addControl #button #myButton "My Button" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b2 "Button 2" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b3 "Button 3" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b4 "Button 4" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b5 "Button 5" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b6 "Button 6" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b7 "Button 7" paramStr:"width:(myRollout.Width - 8 ) align:#center"
rci.addControl #button #b8 "Button 8" paramStr:"width:(myRollout.Width - 8 ) align:#center"

rci.AddControl #Spinner #spn_1 "Deg1"
rci.AddControl #Spinner #spn_2 "Deg2"

fn Button_massDelegate theRollout = -- expand this function to filter the controls according to classof 
(
	for i in theRollout.Controls do 
	(
		if (i.name != "myButton"  and classof i == ButtonControl)  then -- i.name is Case Sensitive !
		( 
			print i.text -- this excutes fine but passing this to a messageBox doesn't /possible Scope issue/
			rci.addHandler i.name #pressed filter:on codeStr:"MessageBox @I Was Pressed@" -- I couldn't reach the I Control here !
		)
		else rci.addHandler i.name #pressed filter:on codeStr:"MessageBox @Isn't this cool@ title:@Wow@"
	)
)

Button_massDelegate myRollout

createDialog (rci.end()) style:#( #style_toolwindow, #style_sysmenu)

Edit : fixed theRollout Scope