2 // a simple NSTableView example - blackrain
4 w = SCWindow.new("NSTableView", Rect(200,500,400,220));
5 w.onClose_({ t.release; v.release; h.release; k.release; l.release; c.release; });
6 p = w.dataptr.asNSReturn;
8 t = SCNSObject("NSTableView", "initWithFrame:", [ Rect(10,10,380,200) ]);
9 t.invoke("setUsesAlternatingRowBackgroundColors:", [ true ]);
11 v = SCNSObject("NSScrollView", "initWithFrame:", [ Rect(10,10,380,200) ]);
13 v.invoke("setHasVerticalScroller:", [ true ]);
14 v.invoke("setHasHorizontalScroller:", [ true ]);
16 k = v.invoke("verticalScroller");
17 k.invoke("setControlSize:",[1]);
19 l = v.invoke("horizontalScroller");
20 l.invoke("setControlSize:",[1]);
22 v.invoke("setAutoresizingMask:", [18]);
23 v.invoke("setDocumentView:", [t]);
25 p.invoke("addSubview:", [v], true);
27 c = SCNSObject("NSTableColumn", "initWithIdentifier:", [ "column_1" ]);
28 c.invoke("setEditable:", [ true ]);
29 c.invoke("setWidth:", [ 200 ]);
30 c.invoke("setResizingMask:", [ 2 ]);
32 h = c.invoke("headerCell");
33 h.invoke("setStringValue:", ["Items"]);
34 h.invoke("setAlignment:", [2]);
36 t.invoke("addTableColumn:", [c], true);
38 t.invoke("setFocusRingType:", [ 1 ]); //NSFocusRingTypeNone
44 i = ["Zero", "One", "Two", "Three", "Four", "Five", "Six"];
45 t.initAction("doAction:");
48 t.nsDelegate.addMethod("tableView:objectValueForTableColumn:row:", "@", "@@i", { arg method, args;
49 [method, args].postln;
54 t.nsDelegate.addMethod("numberOfRowsInTableView:", 'i', "@", { arg method, args;
55 [method, args].postln;
61 t.invoke("setDataSource:", [ t.nsDelegate ], true);
63 t.invoke("reloadData", defer:true);