mirror of https://github.com/Airr/nim-cocoa.git
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.
43 lines
1.1 KiB
43 lines
1.1 KiB
#import <Cocoa/Cocoa.h>
|
|
|
|
#import "col.h"
|
|
|
|
|
|
|
|
@implementation CocoaComboBox
|
|
|
|
@synthesize currentItem;
|
|
@synthesize comboCallBack;
|
|
|
|
- (id)initWithFrame:(NSRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self setEditable: NO];
|
|
[[NSNotificationCenter defaultCenter]
|
|
addObserver:self
|
|
selector:@selector(comboBoxSelectionDidChange:)
|
|
name:NSComboBoxSelectionDidChangeNotification
|
|
object:self];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)comboBoxSelectionDidChange:(NSNotification *)notification {
|
|
// [self setCurrentItem: [self indexOfSelectedItem]];
|
|
self.currentItem = [self indexOfSelectedItem];
|
|
if (self.comboCallBack != NULL) comboCallBack(self);
|
|
}
|
|
@end
|
|
|
|
id createComboBox(id parent,int l, int t, int w, int h, ACTION callback){
|
|
id widget = [[[CocoaComboBox alloc] initWithFrame:NSMakeRect( l, t, w, h )] autorelease];
|
|
if (callback) {
|
|
[widget setComboCallBack:callback];
|
|
// [widget setAction: @selector(click:)];
|
|
}
|
|
|
|
[[parent contentView] addSubview:widget];
|
|
return widget;
|
|
}
|
|
|
|
|