-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCameraMenuButton.m
More file actions
67 lines (57 loc) · 1.54 KB
/
Copy pathCameraMenuButton.m
File metadata and controls
67 lines (57 loc) · 1.54 KB
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
//
// CameraMenuButton.m
// Gawker
//
// Created by Phil Piwonka on 10/2/05.
// Copyright 2005 Phil Piwonka. All rights reserved.
//
#import "CameraMenuButton.h"
@implementation CameraMenuButton
- (id)init
{
if (self = [super init]) {
cameraMenu = nil;
}
return self;
}
- (NSMenu *)cameraMenu
{
return cameraMenu;
}
- (void)setCameraMenu:(NSMenu *)menu
{
[menu retain];
[cameraMenu release];
cameraMenu = menu;
}
- (void)mouseDown:(NSEvent *)anEvent
{
if ([self isEnabled] && cameraMenu) {
[self highlight:YES];
NSPoint menuOrigin = NSMakePoint([self frame].origin.x,
[self frame].origin.y);
NSEvent *event = [NSEvent mouseEventWithType:[anEvent type]
location:menuOrigin
modifierFlags:[anEvent modifierFlags]
timestamp:[anEvent timestamp]
windowNumber:[anEvent windowNumber]
context:[anEvent context]
eventNumber:[anEvent eventNumber]
clickCount:[anEvent clickCount]
pressure:[anEvent pressure]];
[NSMenu popUpContextMenu:cameraMenu withEvent:event forView:self];
[self highlight:NO];
}
}
- (void)mouseUp:(NSEvent *)anEvent
{
if([self isEnabled]) {
[self highlight:NO];
}
}
- (void)dealloc
{
[cameraMenu release];
[super dealloc];
}
@end