forked from atg/Ingredients
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IGKFindWindow.m
96 lines (80 loc) · 2.17 KB
/
IGKFindWindow.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// IGKFindWindow.m
// Ingredients
//
// Created by Alex Gordon on 18/04/2010.
// Written in 2010 by Fileability.
//
#import "IGKFindWindow.h"
@implementation IGKFindWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag
{
if (self = [super initWithContentRect:contentRect styleMask:NSBorderlessWindowMask backing:bufferingType defer:flag])
{
[self setBackgroundColor:[NSColor clearColor]];
[self setOpaque:NO];
[self setHasShadow:NO];
}
return self;
}
//This is a bit of a hack to ensure the parent's window controller gets action messages. We forward everything we don't respond to, to the parent's window controller
- (id)actionForwardee
{
return [[self parentWindow] windowController];
}
- (BOOL)respondsToSelector:(SEL)aSelector
{
if ([super respondsToSelector:aSelector])
return YES;
if ([[self actionForwardee] respondsToSelector:aSelector])
return YES;
return NO;
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector
{
if ([super respondsToSelector:aSelector])
return [super methodSignatureForSelector:aSelector];
id forwardee = [self actionForwardee];
if ([forwardee respondsToSelector:aSelector])
return [forwardee methodSignatureForSelector:aSelector];
return [super methodSignatureForSelector:aSelector];
}
- (void)forwardInvocation:(NSInvocation *)anInvocation
{
id forwardee = [self actionForwardee];
if ([forwardee respondsToSelector:[anInvocation selector]])
{
[anInvocation invokeWithTarget:forwardee];
}
else
{
[super forwardInvocation:anInvocation];
}
}
- (void)becomeKeyWindow
{
[super becomeKeyWindow];
//If this window becomes key, we should make the parent window main
if ([[self parentWindow] canBecomeMainWindow])
[[self parentWindow] makeMainWindow];
}
- (void)becomeMainWindow
{
[super becomeMainWindow];
//Ditto here. For some reason Apple sends -becomeKeyWindow first then -becomeMainWindow
if ([[self parentWindow] canBecomeMainWindow])
[[self parentWindow] makeMainWindow];
}
- (BOOL)canBecomeKeyWindow
{
return YES;
}
- (BOOL)canBecomeMainWindow
{
return YES;
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
@end