Using Cocoa Programmatically
Using Cocoa Programmatically
- Subject: Using Cocoa Programmatically
- From: Matthew Smith <email@hidden>
- Date: Sun, 14 Apr 2002 23:57:24 +1000
Hello,
I'm porting an app to the mac and am having trouble programmatically
creating and adding an NSScroller and an NSOutlineView to my app.
Here is the code for the OutlineView (note I am testing this with the data
object from the OutlineView example in developer/examples):
OutlineData * m_data;
NSOutlineView * m_table;
NSScrollView * myScrollView;
NSTableColumn * m_column1;
NSRect frameRect = NSMakeRect(x, y, width, height);
m_column1 = [[NSTableColumn alloc]initWithIdentifier:@"Column1"];
[[m_column1 headerCell] setStringValue:@"Column1"];
[m_column1 setEditable:false];
m_data = [[OutlineData alloc] init];
m_table = [[NSOutlineView alloc]initWithFrame:frameRect];
[m_table addTableColumn:m_column1];
[m_table setDataSource: m_data];
[m_table setAllowsColumnReordering:false];
[m_table setAllowsColumnResizing:false];
myScrollView = [[NSScrollView alloc]initWithFrame:frameRect];
[myScrollView setDocumentView: m_table];
myScrollView setHasVerticalScroller: true];
[[myWindow contentView] addSubview: myScrollView];
Here is the code for the scroller:
NSScroller * myScroller;
NSRect frameRect = NSMakeRect(x, y, width, height);
myScroller = [[NSScroller alloc] initWithFrame:frameRect];
[myScroller setArrowsPosition: NSScrollerArrowsDefaultSetting];
[myScroller setFloatValue:0.5f knobProportion:0.1f];
[[myWindow contentView] addSubview: myScroller];
The problem with the NSOutlineView is it won't expand objects, it gives an
assertion failure:
Assertion failure in -[NSOutlineView _locationOfColumn:], NSTableView.m:432
Invalid parameter not satisfying: (index >= 0) && (index <= numColumns)
The NSScroller will not display anything but the outline of the control.
Any help would be great,
Matt Smith
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.