NSToolbarItem as Undo
NSToolbarItem as Undo
- Subject: NSToolbarItem as Undo
- From: Craig Bakalian <email@hidden>
- Date: Fri, 26 Nov 2004 03:22:02 -0500
Hi,
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?
Craig Bakalian
www.eThinkingCap.com
_______________________________________________
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