Re: NSTextAttachmentCell as rollover in NSTextView?
Re: NSTextAttachmentCell as rollover in NSTextView?
- Subject: Re: NSTextAttachmentCell as rollover in NSTextView?
- From: Michael Link <email@hidden>
- Date: Thu, 13 Apr 2006 14:59:22 -0500
Wonderful, thank you.
--
Michael
On Apr 13, 2006, at 2:51 PM, Douglas Davidson wrote:
On Apr 13, 2006, at 12:41 PM, Michael Link wrote:
I'm working on writing a view similar to the AddressBook details
view and was considering using custom NSTextAttachmentCell's to
implement some of the embedded controls. A couple years ago
someone mentioned on this list that there was sample code from
Douglas Davidson's WWDC 2003 presentation that showed how to
accomplish some of these tricks in an NSTextView, but I haven't
been able to locate any of the sample code. Does anyone know if
the sample code or presentation is still available and where it
could be found? Thanks.
I did present a custom text attachment demo at WWDC 2003, but it
doesn't cover mouse handling; I've included the important parts
below. There's some sample code showing rollover behavior in the
DTS LayoutManagerDemo sample, but it doesn't involve attachments.
If you have any specific questions, go ahead and ask them on the list.
Douglas Davidson
@implementation Controller
- (void)insertAttachment:(id)sender {
NSTextAttachment *attachment = [[NSTextAttachment alloc]
initWithFileWrapper:nil];
MyAttachmentCell *cell = [[MyAttachmentCell alloc] init];
[attachment setAttachmentCell:cell];
[myTextView insertText:[NSAttributedString
attributedStringWithAttachment:attachment]];
[cell release];
[attachment release];
}
@end
@implementation MyAttachmentCell
- (NSRect)cellFrameForTextContainer:(NSTextContainer *)
textContainer proposedLineFragment:(NSRect)lineFrag glyphPosition:
(NSPoint)position characterIndex:(unsigned)charIndex {
NSLog(@"line frag %@", NSStringFromRect(lineFrag));
return NSMakeRect(0, 0, lineFrag.size.width, 1);
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView characterIndex:(unsigned)charIndex layoutManager:
(NSLayoutManager *)layoutManager {
[[NSColor blackColor] set];
NSLog(@"cell frame %@", NSStringFromRect(cellFrame));
NSRectFill(cellFrame);
}
@end
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden