Last active
October 29, 2019 14:39
-
-
Save mmackh/8821dd8a952df3cd84919f0cd9e42273 to your computer and use it in GitHub Desktop.
Catalyst - NSToolbar Search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSString * toolbarIdentifierSearch = @"Search"; | |
@interface IPDFToolbarItem : NSToolbarItem | |
@property (atomic,readwrite) id view; | |
@property CGSize minSize; | |
@property CGSize maxSize; | |
@end | |
@implementation IPDFToolbarItem | |
@dynamic view; | |
@dynamic minSize; | |
@dynamic maxSize; | |
@end | |
- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSToolbarItemIdentifier)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag | |
{ | |
if (itemIdentifier == toolbarIdentifierSearch) | |
{ | |
id searchField = [NSClassFromString(@"NSSearchField") new]; | |
// fail here if something doesn't work out or customise further | |
IPDFToolbarItem *searchItem = [IPDFToolbarItem itemWithItemIdentifier:toolbarIdentifierSearch barButtonItem:nil]; | |
searchItem.view = searchField; | |
searchItem.maxSize = CGSizeMake(240, 44); | |
return searchItem; | |
} | |
return nil; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment