• 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: Custom Objects in an NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Objects in an NSTextView


  • Subject: Re: Custom Objects in an NSTextView
  • From: Philip Dow <email@hidden>
  • Date: Wed, 4 Jan 2006 19:33:42 +0100

I've always wondered though how it would be possible to use an NSTextAttachmentCell to define a non-rectangular area. As far as I can tell, only NSTextContainer allows this.

As for using a custom NSTextContainer to handle more than one custom layout object, that would also be difficult, no? The text container would need to grab the attributed string, look for custom attachments, determine their position in the text view taking into account the view's size, and then handle the containsPoint: method.

Hmm, good to know that the layout manager can coordinate multiple containers and view. The TextSizing example in the Developer folder demonstrates this, right?

Does anyone know of any examples, though, where a number of custom, non-rectangular objects are stored in a single view or even across multiple views? The TextSizing example only has text.

-Phil

On Jan 4, 2006, at 7:23 PM, Aki Inoue wrote:

Manfred,

I believe implementing a custom NSTextAttachmentCell can serve your purpose. NSTextAttachment allows your to specify an arbitrary an NSCell instance that conforms to the NSTextAttachmentCell protocol. You can start exploring from http://developer.apple.com/ documentation/Cocoa/Conceptual/TextAttachments/index.html

Phil,

If you want text that flows around objects, you will need to use more than one text view each with its own custom text container that defines a bounding rectangle. Hooking up these multiple views so that text editing done in one is reflected in the other ain't easy. Read about the NSTextStorage and NSTextContainer classes.
You don't need to create multiple NSTextContainer/NSTextView to do this. You can have a custom NSTextContainer that returns line fragments flow around your layout objects. And, besides, coordinating multiple NSTextContainer/NSTextView hooked to an NSLayoutManager is automatic.

Aki

What you're asking for is not supported in any simple way by the cocoa text system.

If you want text that flows around objects, you will need to use more than one text view each with its own custom text container that defines a bounding rectangle. Hooking up these multiple views so that text editing done in one is reflected in the other ain't easy. Read about the NSTextStorage and NSTextContainer classes.

If you find an easy way to do it, let me know. I'd kill for embedded images whose text flows.

An alternative might be to use a custom WebView. You could make it editable and maybe (?) override some methods to support object resizing and whatnot.

-Phil

On Jan 4, 2006, at 5:41 PM, Manfred Schubert wrote:

I would like to insert custom objects into an NSTextView. The objects need to flow with the text, they need to be able to change size and respond to clicks. How would I do that? I couldn't find hints in the documentation on how to implement and neither any sample code, so I would be glad if someone could point me to where to start.


Thanks

Manfred
_______________________________________________
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


_______________________________________________ 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



_______________________________________________ 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
  • Follow-Ups:
    • Re: Custom Objects in an NSTextView
      • From: Aki Inoue <email@hidden>
References: 
 >Custom Objects in an NSTextView (From: Manfred Schubert <email@hidden>)
 >Re: Custom Objects in an NSTextView (From: Philip Dow <email@hidden>)
 >Re: Custom Objects in an NSTextView (From: Aki Inoue <email@hidden>)

  • Prev by Date: Re: Custom Objects in an NSTextView
  • Next by Date: Re: Custom Objects in an NSTextView
  • Previous by thread: Re: Custom Objects in an NSTextView
  • Next by thread: Re: Custom Objects in an NSTextView
  • Index(es):
    • Date
    • Thread