summaryrefslogtreecommitdiff
path: root/spinbox_darwin.m
diff options
context:
space:
mode:
Diffstat (limited to 'spinbox_darwin.m')
-rw-r--r--spinbox_darwin.m40
1 files changed, 40 insertions, 0 deletions
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 <Cocoa/Cocoa.h>
+
+@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;
+}