forked from onflapp/gs-webbrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindPanel.m
64 lines (49 loc) · 1.47 KB
/
FindPanel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#import <AppKit/AppKit.h>
#import "FindPanel.h"
@implementation FindPanel
- (id)init {
if (!(self = [super init]))
return nil;
return self;
}
- (void)loadFindStringFromPasteboard {
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
if ([[pasteboard types] containsObject:NSStringPboardType]) {
NSString *string = [pasteboard stringForType:NSStringPboardType];
[self setFindString:string];
}
}
- (void)saveFindStringToPasteboard {
NSPasteboard *pasteboard = [NSPasteboard pasteboardWithName:NSFindPboard];
[pasteboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
[pasteboard setString:[self findString] forType:NSStringPboardType];
}
static id sharedFindPanel = nil;
+ (id)sharedInstance {
if (!sharedFindPanel) {
sharedFindPanel = [[self alloc] init];
[NSBundle loadNibNamed:@"FindPanel" owner:sharedFindPanel];
}
return sharedFindPanel;
}
- (void)performFindPanelAction:(id) sender {
[self saveFindStringToPasteboard];
id resp = [[NSApp mainWindow] firstResponder];
[resp performSelector:@selector(performFindPanelAction:) withObject:sender];
}
- (void) dealloc {
if (self != sharedFindPanel) {
[super dealloc];
}
}
- (NSString*)findString {
return [findText stringValue];
}
- (void)setFindString:(NSString*)string {
[findText setStringValue:string];
}
- (void)orderFrontFindPanel:(id)sender {
[self loadFindStringFromPasteboard];
[panel makeKeyAndOrderFront:nil];
}
@end