Re: NSToolbarItem as Undo
Re: NSToolbarItem as Undo
- Subject: Re: NSToolbarItem as Undo
- From: Fritz Anderson <email@hidden>
- Date: Sat, 27 Nov 2004 15:37:08 -0600
You are aware that NSUndoManager does not implement the methods undo: and redo: ? It implements undo and redo, but those are completely different.
Try it with the target set to nil, which ought to refer the action up the responder chain. The matching between the document's NSUndoManager and the event happens during the responder-chain search.
-- F
On 26 Nov 2004, at 2:22 AM, Craig Bakalian wrote:
I have bought some nice icons for undo and redo. I am trying to implement Undo and Redo as toolbar items. I can't seem to get the action registered with my document [[self document] undoManager].
This is in the toolbar set up method ->
-(NSToolbarItem *)toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *)itemID
willBeInsertedIntoToolbar: (BOOL) willBeInserted
{
else if([itemID isEqual: @"undo"])
{
[toolbarItem setImage: [NSImage imageNamed: @"Undo"]];
[toolbarItem setLabel: @"Undo"];
[toolbarItem setPaletteLabel: @"Undo"];
[toolbarItem setToolTip: @"Undo"];
[toolbarItem setTarget: [[self document] undoManager]];
[toolbarItem setAction: @selector(undo:)];
}
else if([itemID isEqual: @"redo"])
{
[toolbarItem setImage: [NSImage imageNamed: @"Redo"]];
[toolbarItem setLabel: @"Redo"];
[toolbarItem setPaletteLabel: @"Redo"];
[toolbarItem setToolTip: @"Redo"];
[toolbarItem setTarget: [[self document] undoManager]];
[toolbarItem setAction: @selector(redo:)];
}
}
When the app fires up I am expecting the toolbar items to be disabled, because there are no undoes or redoes. But, when the editing happens in my app I have placed the following code.
NSToolbarItem *undo = [self getToolbarItemForIdentifier: @"undo"];
self document] undoManager] canUndo])
{
NSUndoManager *undoer = [[self document] undoManager];
[undo setTarget: undoer];
[undo setAction: @selector(undo:)];
}
While debugging I see the NSUndoManager returned is valid, it has the edit in it. I just can't set my toolbar's action to @selector(undo:). And I have tested this by setting the action to another selector in my app, and it becomes enabled.
Anybody know what is wrong? Is there any example code out there for this?
--
Fritz Anderson
Consulting Programmer Chicago, Illinois
http://resume.manoverboard.org/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden