Last active
January 14, 2022 06:14
-
-
Save adison/41bcfe6d8608505844ed109bfb1d08f7 to your computer and use it in GitHub Desktop.
make source list style nsoutlineview programmatically
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSScrollView* container = [[NSScrollView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)]; | |
container.hasVerticalScroller = YES; | |
container.hasHorizontalScroller = YES; | |
container.wantsLayer = YES; | |
container.identifier = [@(LOGVIEW_OFFSET + i) stringValue]; | |
NSClipView* clipview = [[NSClipView alloc] init]; | |
clipview.autoresizesSubviews = YES; | |
clipview.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; | |
NSOutlineView* outline = [[NSOutlineView alloc] init]; | |
outline.selectionHighlightStyle = NSTableViewSelectionHighlightStyleSourceList; | |
outline.floatsGroupRows = NO; | |
outline.indentationPerLevel = 16.f; | |
outline.indentationMarkerFollowsCell = NO; | |
outline.wantsLayer = YES; | |
outline.layer.backgroundColor = [NSColor secondarySelectedControlColor].CGColor; | |
// outline code | |
NSTableColumn* col1 = [[NSTableColumn alloc] initWithIdentifier:@"col1"]; | |
col1.editable = NO; | |
col1.minWidth = 300000.f; | |
col1.headerCell.stringValue = [NSString stringWithFormat:@"DUT%lu", dutIndex]; | |
[outline addTableColumn:col1]; | |
[outline setOutlineTableColumn:col1]; | |
container.contentView = clipview; | |
clipview.documentView = outline; |
thanks! not knowing of outlinetablecolumn drove me crazy
Very nice, thanks a lot!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are 2 points:
1: the clipped view
2: the table column and outlinetablecolumn