From 6d58f434b74bb0119f493ba8e4508c93b14685d9 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Wed, 29 Oct 2014 12:12:00 -0400 Subject: Added the initial implementaiton of Spinbox on Mac OS X. It doesn't quite work yet. --- spinbox_darwin.m | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spinbox_darwin.m (limited to 'spinbox_darwin.m') diff --git a/spinbox_darwin.m b/spinbox_darwin.m new file mode 100644 index 0000000..f9d6fe4 --- /dev/null +++ b/spinbox_darwin.m @@ -0,0 +1,40 @@ +// 29 october 2014 + +#include "objc_darwin.h" +#include "_cgo_export.h" +#import + +@interface goSpinbox : NSObject { +@public + void *gospinbox; +} +@property NSInteger integerValue; +@end + +@implementation goSpinbox +@synthesize integerValue; +@end + +id newSpinboxStepper(void) +{ + NSStepper *s; + + s = [[NSStepper alloc] initWithFrame:NSZeroRect]; + [s setMinValue:0]; + [s setMaxValue:100]; + [s setIncrement:1]; + [s setAutorepeat:YES]; // hold mouse button to step repeatedly + return (id) s; +} + +id spinboxSetup(id textfield, id stepper, void *gospinbox) +{ + goSpinbox *g; + + g = [goSpinbox new]; + g->gospinbox = gospinbox; + // TODO set any options? + [textfield bind:@"integerValue" toObject:g withKeyPath:@"integerValue" options:nil]; + [stepper bind:@"integerValue" toObject:g withKeyPath:@"integerValue" options:nil]; + return (id) g; +} -- cgit v1.2.3