Prev Up Next
The Undo Mechanism The Undo Mechanism Representation of Undoinfo

Creation and Storage

In Sketch, undoinfo is stored basically in a list in the document object (actually in an instance of the UndoRedo class owned by the document).

A document method that changes the document either creates the undoinfo itself or requires that the functions and methods it calls return the undoinfo. The latter case is the most common, as most operations do not change the state of the document object itself but the state of a layer or a primitive.

In fact, most functions that are expected to return undoinfo do not perform the operation themselves, but call other methods and simply pass the undoinfo they get from those methods back to their caller.

Consider for example the method SetProperties of a group object. A group object has no graphics properties of its own, but setting, e. g., the fill pattern of a group will set the fill pattern of all of the group's children (the objects contained in the group). So its SetProperties method calls the SetProperties method of each of its children and stores the undo info it gets in a list. The undoinfo it returns to its caller will basically say: "to undo the operation you must undo everything in this list".


The Undo Mechanism The Undo Mechanism Representation of Undoinfo
Prev Up Next