blob: f9d6fe435a5db388f3405eb302c002c4c3ebb9e7 (
plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
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;
}
|