Customizing NSSearchField menu
Customizing NSSearchField menu
- Subject: Customizing NSSearchField menu
- From: Jeremy Dronfield <email@hidden>
- Date: Tue, 10 Feb 2004 20:56:42 +0000
Is there a way to intercept the point at which a search field updates
its pull-down menu? I have a search field with a custom menu template
(built in IB) to add the following search parameters: Search in Volume
A; Search in Volume B; Search in All Volumes. Each menu item is
attached to an action method to manage the requested parameters and the
on-states of the menu items:
- (IBAction)setSearchParameter:(id)sender
{
[[[sender menu] itemWithTag:lastSearchParam] setState:NSOffState];
[sender setState:NSOnState];
[self setLastSearchParam:[sender tag]];
}
This works fine, and searching with the selected parameter works fine.
However, my problem is that, when the search field rebuilds its menu
after a search (to update its Recent Searches items) my
"NSOnState/OffState" settings disappear. I've tried this:
[[[[searchField cell] searchMenuTemplate] itemWithTag:lastSearchParam]
setState:NSOnState];
but there doesn't seem to be a suitable place to put it. It seems that
the menu is built at the moment when the button cell is clicked. Is
there a way to intercept that moment and insert my settings? I've tried
implementing the delegate method -menuNeedsUpdate:, but it doesn't
work.
-Jeremy
========================================
email@hidden
theLocustFarm.net:
- fractious fiction at
http://freespace.virgin.net/jeremy.dronfield
========================================
_______________________________________________
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.