Having finished the Insert Frame UI have been connecting the first command Cello. This was something that proved surprisingly easy. The trick seems to be to subclass NSUndoManager and then yo use this as an adaptor for the existing undo system. I have installed my custom undo manager in my NSDocument makeWindowControllers method. Do this and magically it "just works".
The methods I have implemented are:
- (BOOL)canUndo
- (BOOL)canRedo
- (void)undo
- (void)redo
- (NSString *)undoActionName
- (NSString *)redoActionName
These call through to the underlying C++ class (currently there is no exception handling) so my Undo looks something like this:
- (void)undo
{
SOKFile *file = [self file];
SOKUndoList& undo_list = file->GetUndoList();
undo_list.UndoCommand();
}
No comments:
Post a Comment