• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextViews with embedded pictures and vertical alignment
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextViews with embedded pictures and vertical alignment


  • Subject: Re: NSTextViews with embedded pictures and vertical alignment
  • From: Douglas Davidson <email@hidden>
  • Date: Wed, 30 Jun 2004 08:56:32 -0700

On Jun 29, 2004, at 3:32 PM, Nicko van Someren wrote:

Text attachments in the form of a NSTextAttachment need provide an object that conforms to the NSTextAttachmentCell protocol which will be used to draw the attachment representation and handle clicks. The protocol has the following method:

- (NSPoint)cellBaselineOffset
Returns the position where the attachment cell's image should be drawn in text, relative to the current point established in the glyph layout. The image should be drawn so its lower-left corner lies on this point.

At a guess if you make this return a point with a negative Y value then when the cell is laid out it will be placed descending below the text base line. I've not tried it however...

Yes, that is something that custom text attachment cells can use, i.e. custom subclasses of NSTextAttachmentCell, if they need to position their drawing. However, the original problem proposed here sounds like it's just an image attachment, which would most easily be handled by a standard NSTextAttachment and the standard NSTextAttachmentCell that it automatically generates. In that case, the thing to do would be to set a baseline offset via NSBaselineOffsetAttributeName on the attachment character in the attributed string. In TextEdit, you can manipulate this with the Font/Baseline/Raise and Lower menu items; if you're doing it programmatically, you can just directly set a value for the attribute on the text. For those of you at WWDC, I'll be presenting an example of doing this programmatically in session 411.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSTextViews with embedded pictures and vertical alignment
      • From: Nicko van Someren <email@hidden>
References: 
 >NSDateFormatter not validating input (From: David Alter <email@hidden>)
 >NSTextViews with embedded pictures and vertical alignment (From: John Stiles <email@hidden>)
 >Re: NSTextViews with embedded pictures and vertical alignment (From: Nicko van Someren <email@hidden>)

  • Prev by Date: Re: Strategy to split up large class files?
  • Next by Date: Re: 'Attributes' tab in IB inspector
  • Previous by thread: Re: NSTextViews with embedded pictures and vertical alignment
  • Next by thread: Re: NSTextViews with embedded pictures and vertical alignment
  • Index(es):
    • Date
    • Thread