Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > standard PRINT toolbar item wont validate

standard PRINT toolbar item wont validate
Thread Tools
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Feb 4, 2003, 04:04 PM
 
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]; }
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Feb 4, 2003, 04:20 PM
 
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:)]; } }
     
Brass  (op)
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
Feb 4, 2003, 04:26 PM
 
(double post - network problems)
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:45 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2