Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
- Subject: Re: NSLayoutManager's setDefaultAttachmentScaling: not working in custom PDF NSContexts.
- From: Gus Mueller <email@hidden>
- Date: Mon, 30 Jan 2012 15:58:29 -0800
On Jan 30, 2012, at 2:22 PM, Michael Nickerson wrote:
> Hmm, I don't have an answer for you, but I looked at the code. I did a little subclassing of NSLayoutManager, and it looks like the text attachment cell is just ignoring the size given to draw the image in and drawing it full size.
>
> Here's what I used:
>
> <snip>
>
> Add that to the top, and change the layout manager to use it, and it'll draw the rect the layout manager is telling the attachment cell to draw in.
>
> Maybe there's some sort of context related setting that's different between the text view and the PDF context?
That's what I was thinking, but snooping around didn't show anything obviously different between contexts.
However, thanks to your snippet of code I've come up with a quick workaround:
- (void)showAttachmentCell:(NSCell *)cell inRect:(NSRect)rect characterIndex:(NSUInteger)attachmentIndex {
[[cell image] setSize:rect.size];
[super showAttachmentCell:cell inRect:rect characterIndex:attachmentIndex];
}
I'll file a bug on this as Aki suggests. Hopefully this workaround doesn't cause any strange side effects. Since the attributed string is never saved out, modifying the cell this way won't hurt in my case.
-gus
--
August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden