 |
 |
standard PRINT toolbar item wont validate
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
I've created a toolbar with 3 items in it. Two of the items work fine, but the standard print item "NSToolbarPrintItemIdentifier" is always greyed out. I've got no validation code whatsoever as it ought to just validate having a valid target and action (I thought). I've tried adding the validation method and just returning YES every time, but that didn't help either.
What am I doing wrong?
(Some of my code below)
Code:
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
if ( [itemIdentifier isEqualToString:NSToolbarPrintItemIdentifier] )
{
[item setTarget:self];
[item setAction:@selector(printImmediately:)];
}
else if ( [itemIdentifier isEqualToString:@"2ndItem"] )
{
// 2nd Item Code
}
else if ( [itemIdentifier isEqualToString:@"3rdItem"] )
{
// 3rd Item Code
}
return [item autorelease];
}
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
Never mind... solved my own problem again.
I was modifying the print toolbar item in the wrong delegate method. I removed the print item code from the method above, and added the following method to get it to work.
Code:
- (void)toolbarWillAddItem:(NSNotification *)notification
{
NSToolbarItem *itemToAdd = [[notification userInfo] objectForKey:@"item"];
if ( [[itemToAdd itemIdentifier] isEqualToString:NSToolbarPrintItemIdentifier] )
{
[itemToAdd setTarget:self];
[itemToAdd setAction:@selector(printImmediately:)];
}
}
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status:
Offline
|
|
(double post - network problems)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |