You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
nim-cocoa/src/cocoa/widgets/button.m

33 lines
784 B

#import <Cocoa/Cocoa.h>
#import "col.h"
@implementation CocoaButton
@synthesize buttonAction;
- (void) click:(id)sender {
buttonAction(sender);
}
@end
id createButton(id parent, const char* caption, int l, int t, int w, int h, ACTION func){
CocoaButton *widget = [[[CocoaButton alloc] initWithFrame:NSMakeRect( l, t, w, h )] autorelease];
[widget setButtonType:NSMomentaryPushInButton];
[widget setBezelStyle: NSRoundedBezelStyle];
[widget setTitle: [NSString stringWithUTF8String:caption]];
[widget setTarget: widget];
// [widget setAutoresizingMask: NSViewMinXMargin ];
if (func) {
[widget setButtonAction:func];
[widget setAction: @selector(click:)];
}
[[parent contentView] addSubview:widget];
return widget;
}