Skip to content

Instantly share code, notes, and snippets.

Created January 14, 2009 10:03
Show Gist options
  • Select an option

  • Save anonymous/46857 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/46857 to your computer and use it in GitHub Desktop.
@implementation SearchToolbarItem : CPTextField
{
}
- (id)initWithFrame:(CGRect)aFrame
{
self = [super initWithFrame:CGRectMake(0, CGRectGetHeight(aFrame)/2.0 - (22/2), CGRectGetWidth(aFrame)/2, 22)];
[self setPlaceholderString:"Search..."];
[self setAlignment:CPLeftTextAlignment];
[self setFont: [CPFont systemFontOfSize: 12.0]]
[self setBordered:YES];
[self setBezeled:YES];
[self setBezelStyle:CPTextFieldRoundedBezel];
// [self setBezelStyle:CPTextFieldSquareBezel];
[self setEditable:YES];
[self setSelectable:YES];
[self setTarget:self];
[self setAction:@selector(returnPressed:)];
return self;
}
// If the user presses the Return key, notify the database view
- (void)returnPressed:(id)sender
{
CPLogConsole("Object value: <"+[self objectValue]+">", "info");
CPLogConsole("String value: <"+[self stringValue]+">", "info");
[[CPNotificationCenter defaultCenter] postNotificationName:"loadDatabaseSearchedContent" object:[self objectValue]];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment