• 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: NSSearchField (configuring cancel action)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSSearchField (configuring cancel action)


  • Subject: Re: NSSearchField (configuring cancel action)
  • From: Karim Morsy <email@hidden>
  • Date: Sun, 19 Feb 2006 19:34:19 +0100

that works. Thanks alot!

one more questions on searchfields: I've activated "sends search string immediately" in Interface builder.
however, there's an annoying latency as I enter letters in the searchfield. I use the following method to search for key words in a table view that consists of 2 columns:


while (anObject = [enumerator nextObject]) {

string1= [anObject valueForKey:@"artist"];
string2= [anObject valueForKey:@"song"];


NSRange range1= [string1 rangeOfString:[inSender stringValue] options:NSCaseInsensitiveSearch];
NSRange range2= [string2 rangeOfString:[inSender stringValue] options:NSCaseInsensitiveSearch];

if(range1.location == NSNotFound && range2.location == NSNotFound )
continue;
else
[tempArray addObject: anObject]; // tempArray is mutable


	}	

obviously this is not the best way to do it. can anybody suggest a better and especially faster way to do it ?

thanks again,
Karim




On Feb 19, 2006, at 4:12 PM, Mark Munz (DevList) wrote:

To set your action on a search change, in your controlTextdidChange: notification

NSString* searchString = [[aNotification object] stringValue];
if ([searchString length] == 0)
{
   // user canceled search, take whatever action
}
else
{
   // update search
}


Mark Munz


On Feb 19, 2006, at 6:19 AM, Karim Morsy wrote:

Hi,

I've implemented search functionality for a table view. it works fine, but how can I set the action method for the search field's cancel button ?

obviously this is not possible in interface builder (is it ?) and the following programmatic approach didn't work:

	searchCell= [[searchField cancelButtonCell] retain];

	[searchCell setTarget:self];

	[searchCell setAction:@selector(cancelSearch)];


as of what I understood from the docs there's a method passed up the responder chain when the cancel action is invoced. but which method do I have to implement in order to respond to this event ?


any help would be appreciated.

thanks,
Karim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40unmarked.com


This email sent to email@hidden


_______________________________________________ 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:
    • NSSearchField latency and performance (was: configuring cancel action)
      • From: Nicko van Someren <email@hidden>
References: 
 >NSSearchField (configuring cancel action) (From: Karim Morsy <email@hidden>)

  • Prev by Date: Truncating a string with ellipses in a multi-line drawInRect: operation?
  • Next by Date: Questions about NSThread, NSRunloop, Webview
  • Previous by thread: NSSearchField (configuring cancel action)
  • Next by thread: NSSearchField latency and performance (was: configuring cancel action)
  • Index(es):
    • Date
    • Thread