forked from jerrykrinock/ClassesObjC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNSFancyPanel.m
executable file
·55 lines (41 loc) · 1.54 KB
/
NSFancyPanel.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
// NSFancyPanel.m
// FancyAbout
// Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
// See legal notice at end of file.
#import "NSFancyPanel.h"
@interface NSObject (DelegateMethods)
- (BOOL) handlesKeyDown: (NSEvent *) keyDown
inWindow: (NSWindow *) window;
- (BOOL) handlesMouseDown: (NSEvent *) mouseDown
inWindow: (NSWindow *) window;
@end
@implementation NSFancyPanel
// PUBLIC INSTANCE METHODS -- OVERRIDES FROM NSWindow
// NSWindow will refuse to become the main window unless it has a title bar.
// Overriding lets us become the main window anyway.
- (BOOL) canBecomeMainWindow
{
return YES;
}
// Much like above method.
- (BOOL) canBecomeKeyWindow
{
return YES;
}
// Ask our delegate if it wants to handle keystroke or mouse events before we route them.
- (void) sendEvent:(NSEvent *) theEvent
{
// Offer key-down events to the delegats
if ([theEvent type] == NSKeyDown)
if ([[self delegate] respondsToSelector: @selector(handlesKeyDown:inWindow:)])
if ([(id)[self delegate] handlesKeyDown: theEvent inWindow: self])
return;
// Offer mouse-down events (lefty or righty) to the delegate
if ( ([theEvent type] == NSLeftMouseDown) || ([theEvent type] == NSRightMouseDown) )
if ([[self delegate] respondsToSelector: @selector(handlesMouseDown:inWindow:)])
if ([(id)[self delegate] handlesMouseDown: theEvent inWindow: self])
return;
// Delegate wasnÕt interested, so do the usual routing.
[super sendEvent: theEvent];
}
@end