Note that this method waits for a pause in scrolling, which is not an ideal solution in your case. If you keep this timeout at 0.3s, for users who scroll slowly (when they want to precisely adjust object size), undo will be saved every 0.3 seconds, which is still too frequent.
If you set a larger timeout like 1-2 seconds, undo step will be saved with a big delay, during which user may do something else, for example delete the object. And this again can cause the situation when two undo steps are saved at the same time.
Yes 0.3s is a bit slow (but safe) so I just did some tests and I stretched it to a faster delay such as 0.1 sec it works GREAT! even if I go like CRAZY FAST with the wheel I can easily undo back to the MAX limit on the UNDO object until it reaches the end "maxSteps" which I can easily change manually thanks to your dynamic Undo/Redo system dop2000! :)
True that slow scroll is acting weird as you explained, but I don't see other way WITHOUT extra key to add for release to call the undo, so this is good for the Z-Order changes.
I believe that it's very stable because it's only calling the UNDO function "SaveStep" AFTER as I wanted so it's emulating the same timing as I release a key real fast. maybe without the manual delay the scroll do multiple scrolls each time and it SUPER fast, that's the only reason I think it crashed originally.
I WISH we had a built-in action for "AFTER WHEEL FINISHED" like this, it could be sooo useful for many things I do! I'm using the code by rokstars322 which is kind of tiny without the logs/coneole so it's still very nice!
I'm sooo happy that it's solved and works exactly as I imagined! it is very efficient for my project :)
UNDO / Memory Question:
dop2000 I'm curious if you can tell me if it will be a problem if I'll push the maximum amount of undos from 30 to something like 64 or even 128 (which is too much but I'm curious)
Memory wise... will this be an issue to old machines with 4GB RAM? consider there will be many objects on the screen that may also take memory.
What is your suggestion about the maximum amount of UNDO'S for my software to keep it work nicely even on older machines?
It's not that I'm making it FOR old machines, but it's always nice to have MORE machines be able to run my software.
I still don't understand the Debugger/Profiler that should help me out with the memory and CPU (I GUESS?) so I'm asking in Theory if I should go for a HIGHER maximum UNDO limit without risk memory issues on older machines.
I can always let the user change it with a menu I'll make but I'm talking about the defaults for now.
Will 64 / 128 Undos be a REALLY bad idea? or not an issue at all?