上記の 2 つのアプローチを組み合わせる必要がありました。outlineView:shouldShowOutlineCellForItem:
単独では開示三角形用に予約されたスペースが削除されないためです (三角形自体が削除されます)。
代理人:
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldShowOutlineCellForItem:(id)item {
return NO;
}
NSOutlineView のサブクラス:
@implementation ExpandedOutlineView
#define kOutlineCellWidth 11
#define kOutlineMinLeftMargin 6
- (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row {
NSRect superFrame = [super frameOfCellAtColumn:column row:row];
if (column == 0) {
// expand by kOutlineCellWidth to the left to cancel the indent
CGFloat adjustment = kOutlineCellWidth;
// ...but be extra defensive because we have no clue what is going on here
if (superFrame.origin.x - adjustment < kOutlineMinLeftMargin) {
NSLog(@"%@ adjustment amount is incorrect: adjustment = %f, superFrame = %@, kOutlineMinLeftMargin = %f", NSStringFromClass([self class]), (float)adjustment, NSStringFromRect(superFrame), (float)kOutlineMinLeftMargin);
adjustment = MAX(0, superFrame.origin.x - kOutlineMinLeftMargin);
}
return NSMakeRect(superFrame.origin.x - adjustment, superFrame.origin.y, superFrame.size.width + adjustment, superFrame.size.height);
}
return superFrame;
}
@end
結果:
