API  0.9.10
CPSearchField.j
Go to the documentation of this file.
1 /*
2  * CPSearchField.j
3  * AppKit
4  *
5  * Created by cacaodev.
6  * Copyright 2009.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
25 @global CPApp
26 
31 
32 var CPAutosavedRecentsChangedNotification = @"CPAutosavedRecentsChangedNotification";
33 
40 @implementation CPSearchField : CPTextField
41 {
42  CPButton _searchButton;
43  CPButton _cancelButton;
44  CPMenu _searchMenuTemplate;
45  CPMenu _searchMenu;
46 
47  CPString _recentsAutosaveName;
48  CPArray _recentSearches;
49 
50  int _maximumRecents;
51  BOOL _sendsWholeSearchString;
52  BOOL _sendsSearchStringImmediately;
53  BOOL _canResignFirstResponder;
54  CPTimer _partialStringTimer;
55 }
56 
58 {
59  return @"searchfield"
60 }
61 
63 {
64  return @{
65  @"image-search": [CPNull null],
66  @"image-find": [CPNull null],
67  @"image-cancel": [CPNull null],
68  @"image-cancel-pressed": [CPNull null],
69  @"image-search-inset" : CGInsetMake(0, 0, 0, 5),
70  @"image-cancel-inset" : CGInsetMake(0, 5, 0, 0)
71  };
72 }
73 
74 - (id)initWithFrame:(CGRect)frame
75 {
76  if (self = [super initWithFrame:frame])
77  {
78  _maximumRecents = 10;
79  _sendsWholeSearchString = NO;
80  _sendsSearchStringImmediately = NO;
81  _recentsAutosaveName = nil;
82 
83  [self _init];
84 #if PLATFORM(DOM)
85  _cancelButton._DOMElement.style.cursor = "default";
86  _searchButton._DOMElement.style.cursor = "default";
87 #endif
88  }
89 
90  return self;
91 }
92 
93 - (void)_init
94 {
95  _recentSearches = [CPArray array];
96 
97  [self setBezeled:YES];
98  [self setBezelStyle:CPTextFieldRoundedBezel];
99  [self setBordered:YES];
100  [self setEditable:YES];
101  [self setContinuous:YES];
102 
103  var bounds = [self bounds],
104  cancelButton = [[CPButton alloc] initWithFrame:[self cancelButtonRectForBounds:bounds]],
105  searchButton = [[CPButton alloc] initWithFrame:[self searchButtonRectForBounds:bounds]];
106 
107  [self setCancelButton:cancelButton];
108  [self resetCancelButton];
109 
110  [self setSearchButton:searchButton];
111  [self resetSearchButton];
112 
113  _canResignFirstResponder = YES;
114 }
115 
116 
117 #pragma mark -
118 #pragma mark Override observers
119 
120 - (void)_removeObservers
121 {
122  if (!_isObserving)
123  return;
124 
125  [super _removeObservers];
126 
127  [[CPNotificationCenter defaultCenter] removeObserver:self name:CPControlTextDidChangeNotification object:self];
128 }
129 
130 - (void)_addObservers
131 {
132  if (_isObserving)
133  return;
134 
135  [super _addObservers];
136 
137  [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_searchFieldTextDidChange:) name:CPControlTextDidChangeNotification object:self];
138 }
139 
140 // Managing Buttons
145 - (void)setSearchButton:(CPButton)button
146 {
147  if (button != _searchButton)
148  {
149  [_searchButton removeFromSuperview];
150  _searchButton = button;
151 
152  [_searchButton setFrame:[self searchButtonRectForBounds:[self bounds]]];
153  [_searchButton setAutoresizingMask:CPViewMaxXMargin];
154  [self addSubview:_searchButton];
155  }
156 }
157 
163 {
164  return _searchButton;
165 }
166 
172 {
173  var button = [self searchButton],
174  searchButtonImage = (_searchMenuTemplate === nil) ? [self valueForThemeAttribute:@"image-search"] : [self valueForThemeAttribute:@"image-find"];
175 
176  [button setBordered:NO];
177  [button setImageScaling:CPImageScaleAxesIndependently];
178  [button setImage:searchButtonImage];
179  [button setAutoresizingMask:CPViewMaxXMargin];
180 }
181 
186 - (void)setCancelButton:(CPButton)button
187 {
188  if (button != _cancelButton)
189  {
190  [_cancelButton removeFromSuperview];
191  _cancelButton = button;
192 
193  [_cancelButton setFrame:[self cancelButtonRectForBounds:[self bounds]]];
194  [_cancelButton setAutoresizingMask:CPViewMinXMargin];
195  [_cancelButton setTarget:self];
196  [_cancelButton setAction:@selector(cancelOperation:)];
197  [_cancelButton setButtonType:CPMomentaryChangeButton];
198  [self _updateCancelButtonVisibility];
199  [self addSubview:_cancelButton];
200  }
201 }
202 
208 {
209  return _cancelButton;
210 }
211 
217 {
218  var button = [self cancelButton];
219  [button setBordered:NO];
220  [button setImageScaling:CPImageScaleAxesIndependently];
221  [button setImage:[self valueForThemeAttribute:@"image-cancel"]];
222  [button setAlternateImage:[self valueForThemeAttribute:@"image-cancel-pressed"]];
223  [button setAutoresizingMask:CPViewMinXMargin];
224  [button setTarget:self];
225  [button setAction:@selector(cancelOperation:)];
226 }
227 
228 // Custom Layout
235 - (CGRect)searchTextRectForBounds:(CGRect)rect
236 {
237  var leftOffset = 0,
238  width = CGRectGetWidth(rect),
239  bounds = [self bounds];
240 
241  if (_searchButton)
242  {
243  var searchBounds = [self searchButtonRectForBounds:bounds];
244  leftOffset = CGRectGetMaxX(searchBounds) + 2;
245  }
246 
247  if (_cancelButton)
248  {
249  var cancelRect = [self cancelButtonRectForBounds:bounds];
250  width = CGRectGetMinX(cancelRect) - leftOffset;
251  }
252 
253  return CGRectMake(leftOffset, CGRectGetMinY(rect), width, CGRectGetHeight(rect));
254 }
255 
261 - (CGRect)searchButtonRectForBounds:(CGRect)rect
262 {
263  var size = [[self currentValueForThemeAttribute:@"image-search"] size] || CGSizeMakeZero(),
264  inset = [self currentValueForThemeAttribute:@"image-search-inset"];
265 
266  return CGRectMake(inset.left - inset.right, inset.top - inset.bottom + (CGRectGetHeight(rect) - size.height) / 2, size.width, size.height);
267 }
268 
274 - (CGRect)cancelButtonRectForBounds:(CGRect)rect
275 {
276  var size = [[self currentValueForThemeAttribute:@"image-cancel"] size] || CGSizeMakeZero(),
277  inset = [self currentValueForThemeAttribute:@"image-cancel-inset"];
278 
279  return CGRectMake(CGRectGetWidth(rect) - size.width + inset.left - inset.right, inset.top - inset.bottom + (CGRectGetHeight(rect) - size.width) / 2, size.height, size.height);
280 }
281 
282 // Managing Menu Templates
288 {
289  return _searchMenuTemplate;
290 }
291 
297 - (void)setSearchMenuTemplate:(CPMenu)aMenu
298 {
299  _searchMenuTemplate = aMenu;
300 
301  [self resetSearchButton];
302  [self _loadRecentSearchList];
303  [self _updateSearchMenu];
304 }
305 
306 // Managing Search Modes
312 {
313  return _sendsWholeSearchString;
314 }
315 
320 - (void)setSendsWholeSearchString:(BOOL)flag
321 {
322  _sendsWholeSearchString = flag;
323 }
324 
330 {
331  return _sendsSearchStringImmediately;
332 }
333 
338 - (void)setSendsSearchStringImmediately:(BOOL)flag
339 {
340  _sendsSearchStringImmediately = flag;
341 }
342 
343 // Managing Recent Search Strings
349 {
350  return _maximumRecents;
351 }
352 
357 - (void)setMaximumRecents:(int)max
358 {
359  if (max > 254)
360  max = 254;
361  else if (max < 0)
362  max = 10;
363 
364  _maximumRecents = max;
365 }
366 
371 - (CPArray)recentSearches
372 {
373  return _recentSearches;
374 }
375 
381 - (void)setRecentSearches:(CPArray)searches
382 {
383  var max = MIN([self maximumRecents], [searches count]),
384  searches = [searches subarrayWithRange:CPMakeRange(0, max)];
385 
386  _recentSearches = searches;
387  [self _autosaveRecentSearchList];
388 }
389 
395 {
396  return _recentsAutosaveName;
397 }
398 
403 - (void)setRecentsAutosaveName:(CPString)name
404 {
405  if (_recentsAutosaveName != nil)
406  [self _deregisterForAutosaveNotification];
407 
408  _recentsAutosaveName = name;
409 
410  if (_recentsAutosaveName != nil)
411  [self _registerForAutosaveNotification];
412 }
413 
414 // Private methods and subclassing
415 
416 - (CGRect)contentRectForBounds:(CGRect)bounds
417 {
418  var superbounds = [super contentRectForBounds:bounds];
419  return [self searchTextRectForBounds:superbounds];
420 }
421 
422 + (double)_keyboardDelayForPartialSearchString:(CPString)string
423 {
424  return (6 - MIN([string length], 4)) / 10;
425 }
426 
428 {
429  return _searchMenu;
430 }
431 
432 - (BOOL)isOpaque
433 {
434  return [super isOpaque] && [_cancelButton isOpaque] && [_searchButton isOpaque];
435 }
436 
437 - (void)_updateCancelButtonVisibility
438 {
439  [_cancelButton setHidden:([[self stringValue] length] === 0)];
440 }
441 
442 - (void)_searchFieldTextDidChange:(CPNotification)aNotification
443 {
444  if (![self sendsWholeSearchString])
445  {
446  if ([self sendsSearchStringImmediately])
447  [self _sendPartialString];
448  else
449  {
450  [_partialStringTimer invalidate];
451  var timeInterval = [CPSearchField _keyboardDelayForPartialSearchString:[self stringValue]];
452 
453  _partialStringTimer = [CPTimer scheduledTimerWithTimeInterval:timeInterval
454  target:self
455  selector:@selector(_sendPartialString)
456  userInfo:nil
457  repeats:NO];
458  }
459  }
460 
461  [self _updateCancelButtonVisibility];
462 }
463 
464 - (void)_sendAction:(id)sender
465 {
466  [self sendAction:[self action] to:[self target]];
467 }
468 
469 - (BOOL)sendAction:(SEL)anAction to:(id)anObject
470 {
471  [super sendAction:anAction to:anObject];
472 
473  [_partialStringTimer invalidate];
474 
475  [self _addStringToRecentSearches:[self stringValue]];
476  [self _updateCancelButtonVisibility];
477 }
478 
479 - (void)_addStringToRecentSearches:(CPString)string
480 {
481  if (string === nil || string === @"" || [_recentSearches containsObject:string])
482  return;
483 
484  var searches = [CPMutableArray arrayWithArray:_recentSearches];
485  [searches addObject:string];
486  [self setRecentSearches:searches];
487  [self _updateSearchMenu];
488 }
489 
490 - (CPView)hitTest:(CGPoint)aPoint
491 {
492  // Make sure a hit anywhere within the search field returns the search field itself
493  if (CGRectContainsPoint([self frame], aPoint))
494  return self;
495  else
496  return nil;
497 }
498 
500 {
501  return _canResignFirstResponder && [super resignFirstResponder];
502 }
503 
504 - (void)mouseDown:(CPEvent)anEvent
505 {
506  var location = [anEvent locationInWindow],
507  point = [self convertPoint:location fromView:nil];
508 
509  if (CGRectContainsPoint([self searchButtonRectForBounds:[self bounds]], point))
510  {
511  if (_searchMenuTemplate == nil)
512  {
513  if ([_searchButton target] && [_searchButton action])
514  [_searchButton mouseDown:anEvent];
515  else
516  [self _sendAction:self];
517  }
518  else
519  [self _showMenu];
520  }
521  else if (CGRectContainsPoint([self cancelButtonRectForBounds:[self bounds]], point))
522  [_cancelButton mouseDown:anEvent];
523  else
524  [super mouseDown:anEvent];
525 }
526 
561 {
562  var template = [[CPMenu alloc] init],
563  item;
564 
565  item = [[CPMenuItem alloc] initWithTitle:@"Recent Searches"
566  action:nil
567  keyEquivalent:@""];
568  [item setTag:CPSearchFieldRecentsTitleMenuItemTag];
569  [item setEnabled:NO];
570  [template addItem:item];
571 
572  item = [[CPMenuItem alloc] initWithTitle:@"Recent search item"
573  action:@selector(_searchFieldSearch:)
574  keyEquivalent:@""];
575  [item setTag:CPSearchFieldRecentsMenuItemTag];
576  [item setTarget:self];
577  [template addItem:item];
578 
579  item = [[CPMenuItem alloc] initWithTitle:@"Clear Recent Searches"
580  action:@selector(_searchFieldClearRecents:)
581  keyEquivalent:@""];
582  [item setTag:CPSearchFieldClearRecentsMenuItemTag];
583  [item setTarget:self];
584  [template addItem:item];
585 
586  item = [[CPMenuItem alloc] initWithTitle:@"No Recent Searches"
587  action:nil
588  keyEquivalent:@""];
589  [item setTag:CPSearchFieldNoRecentsMenuItemTag];
590  [item setEnabled:NO];
591  [template addItem:item];
592 
593  return template;
594 }
595 
596 - (void)_updateSearchMenu
597 {
598  if (_searchMenuTemplate === nil)
599  return;
600 
601  var menu = [[CPMenu alloc] init],
602  countOfRecents = [_recentSearches count],
603  numberOfItems = [_searchMenuTemplate numberOfItems];
604 
605  for (var i = 0; i < numberOfItems; i++)
606  {
607  var item = [[_searchMenuTemplate itemAtIndex:i] copy];
608 
609  switch ([item tag])
610  {
612  if (countOfRecents === 0)
613  continue;
614 
615  if ([menu numberOfItems] > 0)
616  [self _addSeparatorToMenu:menu];
617  break;
618 
620  {
621  var itemAction = @selector(_searchFieldSearch:);
622 
623  for (var recentIndex = 0; recentIndex < countOfRecents; ++recentIndex)
624  {
625  var recentItem = [[CPMenuItem alloc] initWithTitle:[_recentSearches objectAtIndex:recentIndex]
626  action:itemAction
627  keyEquivalent:[item keyEquivalent]];
628  [recentItem setIndentationLevel:1];
629  [item setTarget:self];
630  [menu addItem:recentItem];
631  }
632 
633  continue;
634  }
635 
637  if (countOfRecents === 0)
638  continue;
639 
640  if ([menu numberOfItems] > 0)
641  [self _addSeparatorToMenu:menu];
642 
643  [item setAction:@selector(_searchFieldClearRecents:)];
644  [item setTarget:self];
645  break;
646 
648  if (countOfRecents !== 0)
649  continue;
650 
651  if ([menu numberOfItems] > 0)
652  [self _addSeparatorToMenu:menu];
653  break;
654  }
655 
656  [item setEnabled:([item isEnabled] && [item action] != nil && [item target] != nil)];
657  [menu addItem:item];
658  }
659 
660  [menu setDelegate:self];
661 
662  _searchMenu = menu;
663 }
664 
665 - (void)_addSeparatorToMenu:(CPMenu)aMenu
666 {
667  var separator = [CPMenuItem separatorItem];
668  [separator setEnabled:NO];
669  [aMenu addItem:separator];
670 }
671 
672 - (void)menuWillOpen:(CPMenu)menu
673 {
674  _canResignFirstResponder = NO;
675 }
676 
677 - (void)menuDidClose:(CPMenu)menu
678 {
679  _canResignFirstResponder = YES;
680 
681  [self becomeFirstResponder];
682 }
683 
684 - (void)_showMenu
685 {
686  if (_searchMenu === nil || [_searchMenu numberOfItems] === 0 || ![self isEnabled])
687  return;
688 
689  var aFrame = [[self superview] convertRect:[self frame] toView:nil],
690  location = CGPointMake(aFrame.origin.x + 10, aFrame.origin.y + aFrame.size.height - 4);
691 
692  var anEvent = [CPEvent mouseEventWithType:CPRightMouseDown location:location modifierFlags:0 timestamp:[[CPApp currentEvent] timestamp] windowNumber:[[self window] windowNumber] context:nil eventNumber:1 clickCount:1 pressure:0];
693 
694  [self selectAll:nil];
695  [CPMenu popUpContextMenu:_searchMenu withEvent:anEvent forView:self];
696 }
697 
698 - (void)_sendPartialString
699 {
700  [super sendAction:[self action] to:[self target]];
701  [_partialStringTimer invalidate];
702 }
703 
704 - (void)cancelOperation:(id)sender
705 {
706  [self setObjectValue:@""];
707  [self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
708 
709  [self _updateCancelButtonVisibility];
710 }
711 
712 - (void)_searchFieldSearch:(id)sender
713 {
714  var searchString = [sender title];
715 
716  if ([sender tag] != CPSearchFieldRecentsMenuItemTag)
717  [self _addStringToRecentSearches:searchString];
718 
719  [self setObjectValue:searchString];
720  [self _sendPartialString];
721  [self selectAll:nil];
722 
723  [self _updateCancelButtonVisibility];
724 }
725 
726 - (void)_searchFieldClearRecents:(id)sender
727 {
728  [self setRecentSearches:[CPArray array]];
729  [self _updateSearchMenu];
730  [self setStringValue:@""];
731  [self _updateCancelButtonVisibility];
732  }
733 
734 - (void)_registerForAutosaveNotification
735 {
736  [[CPNotificationCenter defaultCenter] addObserver:self selector:@selector(_updateAutosavedRecents:) name:CPAutosavedRecentsChangedNotification object:_recentsAutosaveName];
737 }
738 
739 - (void)_deregisterForAutosaveNotification
740 {
741  [[CPNotificationCenter defaultCenter] removeObserver:self name:CPAutosavedRecentsChangedNotification object:_recentsAutosaveName];
742 }
743 
744 - (void)_autosaveRecentSearchList
745 {
746  if (_recentsAutosaveName != nil)
747  [[CPNotificationCenter defaultCenter] postNotificationName:CPAutosavedRecentsChangedNotification object:_recentsAutosaveName];
748 }
749 
750 - (void)_updateAutosavedRecents:(id)notification
751 {
752  var name = [notification object];
753  [[CPUserDefaults standardUserDefaults] setObject:_recentSearches forKey:name];
754 }
755 
756 - (void)_loadRecentSearchList
757 {
758  var name = [self recentsAutosaveName];
759  if (name === nil)
760  return;
761 
762  var list = [[CPUserDefaults standardUserDefaults] objectForKey:name];
763 
764  if (list !== nil)
765  _recentSearches = list;
766 }
767 
768 @end
769 
770 var CPRecentsAutosaveNameKey = @"CPRecentsAutosaveNameKey",
771  CPSendsWholeSearchStringKey = @"CPSendsWholeSearchStringKey",
772  CPSendsSearchStringImmediatelyKey = @"CPSendsSearchStringImmediatelyKey",
773  CPMaximumRecentsKey = @"CPMaximumRecentsKey",
774  CPSearchMenuTemplateKey = @"CPSearchMenuTemplateKey";
775 
776 @implementation CPSearchField (CPCoding)
777 
778 - (void)encodeWithCoder:(CPCoder)coder
779 {
780  [_searchButton removeFromSuperview];
781  [_cancelButton removeFromSuperview];
782 
783  [super encodeWithCoder:coder];
784 
785  if (_searchButton)
786  [self addSubview:_searchButton];
787  if (_cancelButton)
788  [self addSubview:_cancelButton];
789 
790  [coder encodeBool:_sendsWholeSearchString forKey:CPSendsWholeSearchStringKey];
791  [coder encodeBool:_sendsSearchStringImmediately forKey:CPSendsSearchStringImmediatelyKey];
792  [coder encodeInt:_maximumRecents forKey:CPMaximumRecentsKey];
793 
794  if (_recentsAutosaveName)
795  [coder encodeObject:_recentsAutosaveName forKey:CPRecentsAutosaveNameKey];
796 
797  if (_searchMenuTemplate)
798  [coder encodeObject:_searchMenuTemplate forKey:CPSearchMenuTemplateKey];
799 }
800 
801 - (id)initWithCoder:(CPCoder)coder
802 {
803  if (self = [super initWithCoder:coder])
804  {
805  [self setRecentsAutosaveName:[coder decodeObjectForKey:CPRecentsAutosaveNameKey]];
806  _sendsWholeSearchString = [coder decodeBoolForKey:CPSendsWholeSearchStringKey];
807  _sendsSearchStringImmediately = [coder decodeBoolForKey:CPSendsSearchStringImmediatelyKey];
808  _maximumRecents = [coder decodeIntForKey:CPMaximumRecentsKey];
809 
810  var template = [coder decodeObjectForKey:CPSearchMenuTemplateKey];
811 
812  if (template)
813  [self setSearchMenuTemplate:template];
814 
815  [self _init];
816  }
817 
818  return self;
819 }
820 
821 @end
BOOL sendsWholeSearchString()
CPSearchFieldClearRecentsMenuItemTag
Definition: CPSearchField.j:29
void setContinuous:(BOOL flag)
Definition: CPControl.j:350
Definition: CPMenu.h:2
id mouseEventWithType:location:modifierFlags:timestamp:windowNumber:context:eventNumber:clickCount:pressure:(CPEventType anEventType, [location] CGPoint aPoint, [modifierFlags] unsigned modifierFlags, [timestamp] CPTimeInterval aTimestamp, [windowNumber] int aWindowNumber, [context] CPGraphicsContext aGraphicsContext, [eventNumber] int anEventNumber, [clickCount] int aClickCount, [pressure] float aPressure)
Definition: CPEvent.j:130
CPMenu searchMenuTemplate()
void setBezelStyle:(CPTextFieldBezelStyle aBezelStyle)
Definition: CPTextField.j:484
void addSubview:(CPView aSubview)
Definition: CPView.j:512
void encodeWithCoder:(CPCoder aCoder)
Definition: CPTextField.j:2084
void setAction:(SEL anAction)
Definition: CPControl.j:282
BOOL isEnabled()
Definition: CPControl.j:970
var CPSendsSearchStringImmediatelyKey
void textDidChange:(CPNotification note)
Definition: CPTextField.j:1212
An object representation of nil.
Definition: CPNull.h:2
void setTarget:(id aTarget)
Definition: CPControl.j:300
void setBordered:(BOOL shouldBeBordered)
Definition: CPButton.j:768
BOOL becomeFirstResponder()
Definition: CPTextField.j:596
void resetSearchButton()
void addObserver:selector:name:object:(id anObserver, [selector] SEL aSelector, [name] CPString aNotificationName, [object] id anObject)
void setAlternateImage:(CPImage anImage)
Definition: CPButton.j:386
CGPoint locationInWindow()
Definition: CPEvent.j:290
void setCancelButton:(CPButton button)
void selectAll:(id sender)
Definition: CPTextField.j:1688
CPMenuItem separatorItem()
Definition: CPMenuItem.j:536
int width
BOOL resignFirstResponder()
CGRect bounds()
Definition: CPView.j:1302
void postNotificationName:object:(CPString aNotificationName, [object] id anObject)
CPInteger tag()
Definition: CPView.j:956
CPArray recentSearches()
void setImageScaling:(CPImageScaling scaling)
Definition: CPControl.j:940
void addItem:(CPMenuItem aMenuItem)
Definition: CPMenu.j:312
CPNotificationCenter defaultCenter()
void setImage:(CPImage anImage)
Definition: CPButton.j:372
A mutable key-value pair collection.
Definition: CPDictionary.h:2
void setEditable:(BOOL shouldBeEditable)
Definition: CPTextField.j:373
CPWindow window()
Definition: CPView.j:503
void setSearchButton:(CPButton button)
BOOL sendAction:to:(SEL anAction, [to] id anObject)
int windowNumber()
Definition: CPWindow.j:1993
An immutable string (collection of characters).
Definition: CPString.h:2
CPNull null()
Definition: CPNull.j:51
CPButton searchButton()
CGPoint convertPoint:fromView:(CGPoint aPoint, [fromView] CPView aView)
Definition: CPView.j:2208
var CPAutosavedRecentsChangedNotification
Definition: CPSearchField.j:32
global CPApp CPSearchFieldRecentsTitleMenuItemTag
Definition: CPSearchField.j:27
BOOL sendAction:to:(SEL anAction, [to] id anObject)
Definition: CPControl.j:319
SEL action()
Definition: CPControl.j:290
CGRect convertRect:toView:(CGRect aRect, [toView] CPView aView)
Definition: CPView.j:2309
BOOL sendsSearchStringImmediately()
var CPMaximumRecentsKey
CGRect contentRectForBounds:(CGRect bounds)
Definition: CPTextField.j:1802
CGRect searchButtonRectForBounds:(CGRect rect)
void setAutoresizingMask:(unsigned aMask)
Definition: CPView.j:1487
BOOL isOpaque()
Definition: CPView.j:2773
CGRect searchTextRectForBounds:(CGRect rect)
int length()
Definition: CPString.j:186
CPButton cancelButton()
void setStringValue:(CPString aString)
Definition: CPControl.j:629
A notification that can be posted to a CPNotificationCenter.
Definition: CPNotification.h:2
CPTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:(CPTimeInterval seconds, [target] id aTarget, [selector] SEL aSelector, [userInfo] id userInfo, [repeats] BOOL shouldRepeat)
Definition: CPTimer.j:58
CPString name
Definition: CPException.j:47
void setObjectValue:(id aValue)
Definition: CPTextField.j:1304
void setSearchMenuTemplate:(CPMenu aMenu)
id target()
Definition: CPControl.j:308
CPString stringValue()
Definition: CPControl.j:613
var CPSearchMenuTemplateKey
void resetCancelButton()
A timer object that can send a message after the given time interval.
Definition: CPTimer.h:2
Defines methods for use when archiving & restoring (enc/decoding).
Definition: CPCoder.h:2
var CPSendsWholeSearchStringKey
CPMenu defaultSearchMenuTemplate()
Sends messages (CPNotification) between objects.
var CPRecentsAutosaveNameKey
CPDictionary themeAttributes()
Definition: CPSearchField.j:62
CPNotification notificationWithName:object:userInfo:(CPString aNotificationName, [object] id anObject, [userInfo] CPDictionary aUserInfo)
void setRecentsAutosaveName:(CPString name)
BOOL resignFirstResponder()
Definition: CPTextField.j:792
void mouseDown:(CPEvent anEvent)
Definition: CPTextField.j:990
id initWithTitle:action:keyEquivalent:(CPString aTitle, [action] SEL anAction, [keyEquivalent] CPString aKeyEquivalent)
Definition: CPMenuItem.j:121
void setBezeled:(BOOL shouldBeBezeled)
Definition: CPTextField.j:464
CPString recentsAutosaveName()
void setRecentSearches:(CPArray searches)
void removeObserver:name:object:(id anObserver, [name] CPString aNotificationName, [object] id anObject)
Definition: CPEvent.h:2
void setBordered:(BOOL shouldBeBordered)
Definition: CPTextField.j:509
CPView superview()
Definition: CPView.j:486
CPString defaultThemeClass()
Definition: CPSearchField.j:57
CGRect frame()
Definition: CPView.j:1022
void popUpContextMenu:withEvent:forView:(CPMenu aMenu, [withEvent] CPEvent anEvent, [forView] CPView aView)
Definition: CPMenu.j:857
CPSearchFieldRecentsMenuItemTag
Definition: CPSearchField.j:28
CGRect cancelButtonRectForBounds:(CGRect rect)
CPSearchFieldNoRecentsMenuItemTag
Definition: CPSearchField.j:30
id alloc()
Definition: CPObject.j:130
Definition: CPView.j:136