I have problems for customizing the text in the NSCell
for the NSTableView
. Below is the main window:
The window has a table view which shows an icon, a title,a progress indicator and a message.As my computer is 10.6, I implement it with cell-based tableview. The custom cell is based on the ImageAndTextCell which is provided by the Apple. The message is drawn like:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSMutableDictionary *fontAttributes = [NSMutableDictionary dictionaryWithCapacity:1];
[fontAttributes setObject:[NSFont fontWithName:@"Hei" size:12] forKey:NSFontAttributeName];
if (!self.msg) {
self.msg = @"default";
}
CGRect textFrame = cellFrame;
textFrame.origin.x += 20;
textFrame.origin.y += 20;
[self.msg drawAtPoint:textFrame.origin withAttributes:fontAttributes];
}
msg
is a copy NSString property of the cell.
I met two problems:
1 when I select one cell, the message will dismissed,just like:
Only you unselect it, will it show again. How should I do to fix it?
2 I need to custom the title. As you can see, each cell has a title, sae or IBM. It is the value returned from the delegate:
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;
Can I change the position, color, or font of it?