PDA

View Full Version : Custom NSCell




hyabusa
Oct 7, 2010, 07:04 AM
Hi,

I have an NSTableView with a custom NSCell, I draw the text/images etc.. in the cell using

- (void)drawInteriorWithFrame:(NSRect)theCellFrame inView:(NSView *)theControlView
{
NSImage *frameimg = [NSImage imageNamed: @"photo_frame"];
[frameimg setFlipped:YES];
[frameimg drawInRect:NSMakeRect(7, theCellFrame.origin.y+9.0, 56, 57) fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}

That works perfectly for NSImage/NSString/NSAttributedString etc.. but I need to display links in my text and allow them to be clickable.

To do this I wanted to use NSTextView with the attributed string set that has the link information inside it, is there anyway to draw an NSTextView inside my custom cell?

I can add the NSTextView to theControlView at the correct position but if you do that then it will keep getting added every time the cell redraws and it doesn't work very well.

I'm used to the iPhone and trying to get used to cocoa on the mac so excuse my stupidity :)


Thanks.