thank you jens, that is most helpful, i will take a look at the webview. On Sun, Nov 22, 2009 at 6:47 PM, Jens Alfke <[email protected]> wrote:
> > On Nov 22, 2009, at 2:06 AM, Richard wrote: > > > as part of an application i am working on, i have made a chat client in > the > > style of ichat with pics and bubbles and such. i am currently doing this > > using an NSTableView > > This works, but you'll find it difficult to handle multi-line messages. > NSTableView can have variable row heights these days, but whenever the view > width changes you'd have to scan every message counting the number of line > breaks and set the row's height accordingly. > > > now, i would like to be able to select and copy sections of the text > > displayed in each chat bubble, but i am unable to work out how to do > this. i > > would also like to be able to make text links clickable. i understand > that > > NSTextView has both these capabilities, but am i correct in thinking that > > you cannot have an NSView in an NSCell? > > That's basically correct. The reason is that the cell doesn't have a > specific position in the view; it's used to draw every single row; but a > view has to have a single position. There are some workarounds for this but > they involve adding a subview for every row, which doesn't scale well. > > The way iChat worked originally was to use a single NSTextView for the > whole chat, with a paragraph per message, and draw a custom background that > looked up the layout bounds of each paragraph to find the bounding box of > its balloon. This sounds simple, but the details got very messy, and I don't > recommend it. > > These days the best way is to use a WebView and a custom CSS stylesheet. > Make each message a <div> element with a particular class, and the > stylesheet describes the background and border. WebKit supports some > nonstandard CSS border attributes that make it easy to draw the border by > tiling a single image. You use the DOM API to insert a <div> when there's a > new message. > > —Jens > > _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
