General XMetaL Discussion
scotth August 8, 2011 at 7:23 pm
Accessing the Undo StackAugust 8, 2011 at 7:23 pmParticipants 4Replies 5Last Activity 11 years, 4 months ago
Using XMetaL 6.0, is there any way to access the undo and redo stacks? In particular, I am just wanting to know whether or not they contain anything, so that I can enable and disable these commands appropriately.
ScottDerek Read August 8, 2011 at 7:42 pm
Reply to: Accessing the Undo StackAugust 8, 2011 at 7:42 pm
You cannot obtain a list of actions that were done (I assume that is what you want). This would be a nice to have feature (and we've thought about it but it has not come the top of the list yet). We've thought it might be nice to assign names to everything a user could do and then expose that in a drop down or similar on the Undo/Redo buttons, which might also allow you to Undo/Redo multiple actions at once. If that work was done a corresponding API to expose that might be made. That would likely be trivial, but the main work would need to be done first, and that does not appear to be trivial.
I'm not sure when it would be necessary to programmatically enable/disable the Undo/Redo commands. Can you describe in more detail, or give a usage example?
Knowing this might help me push such a feature up the list a little bit if it sounds like a need others could benefit from. Or perhaps there are other ways to currently accomplish what you need to do by tackling it from a different angle.scotth August 8, 2011 at 8:37 pm
Reply to: Accessing the Undo StackAugust 8, 2011 at 8:37 pm
I was wanting to provide a little bit better context display for my undo and redo buttons, disabling undo when the undo stack was clear. If there's not an easy way to access the stack or a count of the stack items in the current version, then it's not a big deal.Derek Read August 8, 2011 at 8:45 pm
Reply to: Accessing the Undo StackAugust 8, 2011 at 8:45 pm
Why do you need to do this manually? The buttons should enable / disable on their own (unless you've found a bug, or I still don't understand the context).scotth August 9, 2011 at 12:38 pm
Reply to: Accessing the Undo StackAugust 9, 2011 at 12:38 pm
I probably should have been a bit clearer. I am developing a solution using XMAX, so you have to do these types of things on your own. The webmax demo simply enables or disables these buttons based upon whether a document is open.Derek Read August 10, 2011 at 9:32 pm
Reply to: Accessing the Undo StackAugust 10, 2011 at 9:32 pm
I would have to say that seems to be a hole in our APIs for XMAX. Basically, you need to be “optimistic” when designing your UI. In other words, enable the UI if ActiveDocument.Saved == false, or keep track of whether the user has saved in your part of the code. This probably also means making a decision as to whether you allow an “undo paste save” feature or not (in which case I suppose the enable/disable logic might be different or not doable, ie: always on).
Some (probably pretty advanced) ChangedNodesList monitoring could possibly get better results, though I have not tried to do anything like this.
- You must be logged in to reply to this topic.