• 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
NSSearchField Menu Enabling Troubles...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSearchField Menu Enabling Troubles...


  • Subject: NSSearchField Menu Enabling Troubles...
  • From: Oliver Cameron <email@hidden>
  • Date: Mon, 31 May 2004 14:13:49 +0100

Hi guys,

I have a NSSearchField which has a menu attached to it. I attach the menu via this code:

- (void)setupSearchBar
{
NSMenu *cellMenu = [[[NSMenu alloc] initWithTitle:@"Search Menu"] autorelease];
NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"PHP.Net Manual" action:@selector(setPHP:) keyEquivalent:@""];
NSMenuItem *item2 = [[NSMenuItem alloc] initWithTitle:@"MySQL Manual" action:@selector(setMySQL:) keyEquivalent:@""];
id searchCell = [searchBar cell];
[cellMenu insertItem:item atIndex:0];
[cellMenu insertItem:item2 atIndex:1];
[item release];
[item2 release];
[searchCell setSearchMenuTemplate:cellMenu];
}

Now, the menu is attached fine, but the menu items are not enabled, they are just grey. I had a look in Apple's docs and this is how they do it too. In case its needed, here are the methods I use (setPHP and setMySQL):

- (void)setPHP:(id)sender
{
id searchBarCell = [searchBar cell];
[searchBarCell setPlaceholderString:@"PHP.Net Manual"];
[phpMenuItem setState:NSOnState];
[sqlMenuItem setState:NSOffState];
[[NSUserDefaults standardUserDefaults] setObject:@"PHP.Net Manual" forKey:@"HelpSearchMode"];
}

- (void)setMySQL:(id)sender
{
id searchBarCell = [searchBar cell];
[searchBarCell setPlaceholderString:@"MySQL Manual"];
[sqlMenuItem setState:NSOnState];
[phpMenuItem setState:NSOffState];
[[NSUserDefaults standardUserDefaults] setObject:@"MySQL Manual" forKey:@"HelpSearchMode"];
}

Now, you would have thought that it would have worked, but it won't! I had a look in the archives, and someone else had a similar problem but got no reply.

Any ideas?

Thanks,
Oliver
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSSearchField Menu Enabling Troubles...
      • From: Jeremy Dronfield <email@hidden>
  • Prev by Date: Re: Window won't show a second time.
  • Next by Date: Re: Code Guidelines
  • Previous by thread: Re: NSSavePanel can't enter filename
  • Next by thread: Re: NSSearchField Menu Enabling Troubles...
  • Index(es):
    • Date
    • Thread