• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Toolbar bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Toolbar bug?


  • Subject: Re: Toolbar bug?
  • From: Chris Giordano <email@hidden>
  • Date: Mon, 20 Dec 2004 18:08:02 -0500

Glen,

On Dec 20, 2004, at 5:07 PM, Glen Simmons wrote:

My app has several different window types with different toolbars and toolbar items. The problem is that you can drag the default set of icons from window A's Customize Toolbar pane into window B's toolbar. This results in window B having an empty toolbar. I tried this in other cocoa apps (Mail, Xcode) and the same thing happened. I'm guessing this is a known issue, is there a workaround for it?


I think you can resolve this issue by using the delegate to restrict the items that the toolbar allows.


Something like the following should do the trick, I think. (I can't say that I can speak from experience, but I think this would work. And the usual email-written disclaimers apply.)


1. Create your toolbars using unique identifier for each window type: e.g.,


NSToolbar * toolbar = [[[NSToolbar alloc] initWithIdentifier:@"toolbarA"] autorelease];
// add stuff, configure etc...
// set the delegate
[windowOfTypeA setToolbar:toolbar];


toolbar = [[[NSToolbar alloc] initWithIdentifier:@"toolbarB"] autorelease];
// add stuff, configure etc...
// set the delegate
[windowOfTypeB setToolbar:toolbar];



2. Either have two different delegates for the toolbars, or have one delegate that differentiates the toolbars by the identifier. If you have two different delegates, just return the appropriate array of identifiers from the delegate. If you have one delegate for both types, you can do something like the following:


- (NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar;
{
	NSString * identifier = [toolbar identifier];
	NSArray * result = nil;
	if ([identifier isEqualToString:@"toolbarA"])
		result = [NSArray arrayWithObjects:@"itemA-1", @"itemA-2", nil];
	else if ([identifier isEqualToString:@"toolbarB"])
		result = [NSArray arrayWithObjects:@"itemB-1", @"itemB-2", nil];

	return result;
}



chris

_______________________________________________
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


  • Follow-Ups:
    • Re: Toolbar bug?
      • From: Glen Simmons <email@hidden>
References: 
 >Toolbar bug? (From: Glen Simmons <email@hidden>)

  • Prev by Date: Re: Renaming files?
  • Next by Date: Re: NSBeginAlertSheet (II)
  • Previous by thread: Re: Toolbar bug?
  • Next by thread: Re: Toolbar bug?
  • Index(es):
    • Date
    • Thread