• 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 problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSSearchField problem


  • Subject: NSSearchField problem
  • From: Michael de Haan <email@hidden>
  • Date: Sat, 12 Oct 2013 18:21:47 -0700

Hi all
I am struggling to solve this problem.
I wish to implement a searchField similar to the "Find" of Xcode's IDE editor, where, for example, "Recent Results" places the item chose into the SearchField and performs the search with the chosen string. The current setup( in OSx)  is a simple TableView, an Array controller which populates the tableView with Managed Object instances, and works as expected. ( ie Add, Remove are implemented through the controller).
I have implemented the direct search by creating a predicate with the inputString of the searchField and applying that to the arrayController, which works as expected. (done in the delegate ControlTextDidChange method);

The code I am using to try to implement the issue mentioned above is as follows. (unapologetically "modified" from Apple's searchField example)

-(void)setUpSearchField{

    if ([self.searchField respondsToSelector:@selector(setRecentSearches:)]) {



        NSMenu * searchMenu = [[NSMenu alloc]initWithTitle:@"Search Menu"];
        [searchMenu setAutoenablesItems:YES];



        NSMenuItem * recentSearchesItem = [[NSMenuItem alloc]initWithTitle:@"Recent Names"
                                                                    action:@selector(searchWithRecentNames:)
                                                             keyEquivalent:@""];
        [recentSearchesItem setTarget:self];
        [recentSearchesItem setTag:NSSearchFieldRecentsMenuItemTag];
        [searchMenu insertItem:recentSearchesItem atIndex:0];


        id searchCell = [self.searchField cell];
        [searchCell setSearchMenuTemplate:searchMenu];




    }


}

The selector( ie (searchWithRecentNames:) is never called. I do note that if the tag "NSSearchFieldRecentsMenuItemTag" is omitted, it is called, but that is not following the example as suggested by Apple in their SearchField example.
I have tried the following delegate method.
control:textDidChange....which, I learnt is only called with a user interaction.
I realize that the other delegate methods tried are all under the heading of "TextField" or "Control" delegate methods, but with equal luck.
Clearly, what I **think** I need is a delegate method that is triggered when the "recent searches" string is selected and clicked, but that is eluding me.
A pointer in the right direction would be greatly appreciated.
Thanks in advance.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: NSSearchField problem
      • From: Jerry Krinock <email@hidden>
  • Prev by Date: Re: collection of applications
  • Next by Date: Re: NSSearchField problem
  • Previous by thread: Re: Correct usage of NSTextView and NSFindBar
  • Next by thread: Re: NSSearchField problem
  • Index(es):
    • Date
    • Thread