[Closed] Undo problem, any suggestions?
I’m having some issues with a script as I need the ability to have an undo. So here is the scenario.
There is a spinner that changes a value on an object. The user grabs the spinner with the mouse and pushes up increasing the value of the spinner. If an undo context is wrapped around the expression it is storing an undo for every step the spinner took so when an undo is performed it only undoes a small fraction of the complete action the user performed.
Any suggestions on getting around this? In one tool I did some time ago I created my own undo buffer but that isn’t really what I want this time around. I need it to work with the Max undo stack.
How about leveraging the [color=white][/color]
on <spinner> buttonup do <expr>
For example have the same routine in the value changed handler without the undo and then catch the final state in the button up handler creating the undo record.
Maybe you’d need to store the start value in buttondown and capture changed value then cancel out the spinner changed value, start a undo clause and reapply the changed value.
-Johan
Kevin pointed me to this thread, I didn’t even know about this.
http://forums.cgsociety.org/showpost.php?p=6688786&postcount=2
Haha I just was running into this myself, don’t know much about it, let me know if you find a good description of theHold somewhere.
I was able to boil down my complex script into a single undo action by using it but I’m not sure if it was done in a stable manner or not.
theHold.Begin() –where the script action kicks off
theHold.Accept() –where the script closes down or completes your action.
(I’d like to think its as simple as that, but I’m just not sure yet)