2 // NSControl on SCWindows example - blackrain
3 // Linked NSSlider NSTextField
5 w = SCWindow.new("NSControl on SCWindow", Rect(10,400,400,150)).front;
6 w.onClose_({ [l, c, d, e].do(_.release) });
7 p = w.dataptr.asNSReturn;
9 l = SCNSObject("NSSlider", "initWithFrame:", [ Rect(10,50,380,22) ]);
10 l.initAction.action_({ arg v, val; d.invoke("setFloatValue:", [val], true) });
12 p.invoke("addSubview:", [ l ], true);
15 c.invoke("setControlSize:", [ 1 ], true); // small
18 d = SCNSObject("NSTextField", "initWithFrame:", [ Rect(10,10,100,20) ]);
20 p.invoke("addSubview:", [ d ], true);
22 d.initAction.action_({ arg v, val; l.invoke("setFloatValue:", [val], true) });
25 f = SCSlider.new(w, Rect(10,80,380,16));
28 c.invoke("setControlSize:", [ 0 ], true); // regular
29 c.invoke("setControlSize:", [ 1 ], true); // small
30 c.invoke("setControlSize:", [ 2 ], true); // mini
37 w = SCWindow.new("NSButton", Rect(10,530,280,100)).front;
38 w.onClose_({ b.release });
39 p = w.dataptr.asNSReturn;
41 b = SCNSObject("NSButton", "initWithFrame:", [ Rect(10,5,88,24) ]);
42 b.invoke("setTitle:", ["OK"], true);
43 b.invoke("setBezelStyle:", [10], true); // NSSmallSquareBezelStyle
44 b.initAction("doAction:");
45 b.nsAction.action_({ arg v, val; [v, val].postln });
47 p.invoke("addSubview:", [ b ], true);
56 w = SCWindow.new("NSTextView", Rect(10,400,500,280)).front;
57 w.view.decorator = FlowLayout(w.view.bounds);
58 w.onClose_({ [v, t].do(_.release) });
59 p = w.dataptr.asNSReturn;
61 t = SCNSObject("NSTextView", "initWithFrame:", [ Rect(10,35,480,220) ]);
62 v = SCNSObject("NSScrollView", "initWithFrame:", [ Rect(10,35,480,220) ]);
63 v.invoke("setDocumentView:", [t]);
64 v.invoke("setHasVerticalScroller:", [ true ]);
65 p.invoke("addSubview:", [ v ]);