forked from mojbro/gocoa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
custombutton.m
27 lines (22 loc) · 858 Bytes
/
custombutton.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
#include "_cgo_export.h"
#import "button.h"
@implementation CustomButton
- (void)mouseDown:(NSEvent *)theEvent {
NSPoint p = [self convertPoint:theEvent.locationInWindow fromView:nil];
onCustomButtonClicked([self goButtonID], p.x, p.y,
theEvent.buttonNumber != 1);
}
@end
ButtonPtr CustomButton_New(int goButtonID, int x, int y, int w, int h) {
CustomButton *nsButton =
[[[CustomButton alloc] initWithFrame:NSMakeRect(x, y, w, h)] autorelease];
[nsButton setGoButtonID:goButtonID];
[nsButton setButtonType:NSButtonTypeMomentaryLight];
[nsButton setBezelStyle:NSBezelStyleRounded];
return (ButtonPtr)nsButton;
}
void Window_AddCustomButton(void *wndPtr, ButtonPtr btnPtr) {
CustomButton *button = (CustomButton *)btnPtr;
NSWindow *window = (NSWindow *)wndPtr;
[[window contentView] addSubview:button];
}