• 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
How I was able to select between 3 different toolbars in one window, is there a better way?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How I was able to select between 3 different toolbars in one window, is there a better way?


  • Subject: How I was able to select between 3 different toolbars in one window, is there a better way?
  • From: James Housley <email@hidden>
  • Date: Tue, 8 Feb 2005 14:49:52 -0500

I have an App with 3 tabs that select 3 different views to access different parts. I wanted a unique toolbar for each of the tabs. The variable "tabsFirsts_index" is used to track which tab is the active one, this is needed so I can do some stuff on the will change and did change where I want to know the last table the user was on. Anyways, I created the 3 different toolbars and saved them out into a NSDictionary, and then used those dictionaries to switch between them.

This works, but during development I had some problems with AllowUserCustomizations was enabled, haven't tried enabling that again. But, for now that is okay because the tool bar is not customizable. However, I do see this as a little hooky. I am sure there is a better way, possibly to even have more then one toolbar visible (not that I want to).

One thought I had was to somehow create some borderless transparent windows and put the toolbars in those windows and some how attach those windows in to my main window. It seems like this might be a more proper method, but is beyond anything I have tried. Does this sound like the right approach?

Jim


- (void)setupToolbar
{
NSWindow *tmpWindow;

// Create a new toolbar instance, and attach it to our document window
currentToolbar = [[[NSToolbar alloc] initWithIdentifier:FirstToolbarIdentifier] autorelease];
FirstToolbar = [[[NSToolbar alloc] initWithIdentifier:FirstToolbarIdentifier] autorelease];
SecondToolbar = [[[NSToolbar alloc] initWithIdentifier:SecondToolbarIdentifier] autorelease];
ThirdToolbar = [[[NSToolbar alloc] initWithIdentifier:ThirdToolbarIdentifier] autorelease];


// Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults
[currentToolbar setAllowsUserCustomization:NO];
[currentToolbar setAutosavesConfiguration:NO];
[currentToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[FirstToolbar setAllowsUserCustomization:NO];
[FirstToolbar setAutosavesConfiguration:NO];
[FirstToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[SecondToolbar setAllowsUserCustomization:NO];
[SecondToolbar setAutosavesConfiguration:NO];
[SecondToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[ThirdToolbar setAllowsUserCustomization:NO];
[ThirdToolbar setAutosavesConfiguration:NO];
[ThirdToolbar setDisplayMode:NSToolbarDisplayModeIconOnly];


    // We are the delegate
    [currentToolbar setDelegate:self];
    [FirstToolbar setDelegate:self];
    [SecondToolbar setDelegate:self];
    [ThirdToolbar setDelegate:self];

// Attach the toolbar to the document window
tabsFirsts_index = 2;
tmpWindow = [[NSWindow alloc] init];
[tmpWindow setToolbar:ThirdToolbar];
[ThirdToolbar setVisible:YES];
ThirdToolbarDictionary = [[NSDictionary alloc] initWithDictionary:[ThirdToolbar configurationDictionary]];
[tmpWindow release];

tabsFirsts_index = 1;
tmpWindow = [[NSWindow alloc] init];
[tmpWindow setToolbar:SecondToolbar];
[SecondToolbar setVisible:YES];
SecondToolbarDictionary = [[NSDictionary alloc] initWithDictionary:[SecondToolbar configurationDictionary]];
[tmpWindow release];

tabsFirsts_index = 0;
tmpWindow = [[NSWindow alloc] init];
[tmpWindow setToolbar:FirstToolbar];
[FirstToolbar setVisible:YES];
FirstToolbarDictionary = [[NSDictionary alloc] initWithDictionary:[FirstToolbar configurationDictionary]];
[tmpWindow release];

[currentToolbar setConfigurationFromDictionary:FirstToolbarDictionary];
[documentWindow setToolbar:currentToolbar];
[currentToolbar setVisible:YES];
}


- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem
{
if ([tabsFirst tabViewItemAtIndex:0] == tabViewItem)
{
tabsFirst_index = 0;
[currentToolbar setConfigurationFromDictionary:FeedToolbarDictionary];
}
else if ([tabsFirst tabViewItemAtIndex:1] == tabViewItem)
{
tabsFirst_index = 1;
[currentToolbar setConfigurationFromDictionary:ItemToolbarDictionary];
}
else if ([tabsFirst tabViewItemAtIndex:2] == tabViewItem)
{
tabsFirst_index = 2;
[currentToolbar setConfigurationFromDictionary:ImageToolbarDictionary];
}
}


--

/"\   ASCII Ribbon Campaign  .
\ / - NO HTML/RTF in e-mail  .
 X  - NO Word docs in e-mail .
/ \ -----------------------------------------------------------------
email@hidden      http://www.FreeBSD.org     The Power to Serve
email@hidden  http://www.TheHousleys.net
---------------------------------------------------------------------
Do not meddle in the affairs of dragons, for you are crunchy and taste
    good with ketchup.

_______________________________________________
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: How I was able to select between 3 different toolbars in one window, is there a better way?
      • From: Andy Armstrong <email@hidden>
  • Prev by Date: Re: Drag and Drop with tableviews...
  • Next by Date: Re: How I was able to select between 3 different toolbars in one window, is there a better way?
  • Previous by thread: Re: Drag and Drop with tableviews...
  • Next by thread: Re: How I was able to select between 3 different toolbars in one window, is there a better way?
  • Index(es):
    • Date
    • Thread