I¹ve successfully managed to override Paste and PerformDrag to embed images
which are resizable and with specified fractional (fraction of
height)baseline offsets.  They also archive and unarchive properly.  I¹m
using a custom TextAttachmentextCell which archives the size and the
fractional baseline offset, and returns the appropriate values to draw
properly.  Undo/redo even works.  However, it¹s still not right.  I cannot
copy/pasts or drag/drop a text segment containing the attachment without
losing the attachment.  NSTextView¹s handling of images, without my
enhancements, does this correctly.  So what am I missing?

I don¹t really understand the various ³fix² methods.  When I did my own text
editor (pre-OSX), which was uses in some Mayo Clinic multimedia CDs, I
handled all this automatically when pasting, etc.  I did put in a
fixAttachmentAttributeInRange call after insertion.  That didn¹t help.


On 8/10/13 12:31 PM, "Gordon Apple" <g...@ed4u.com> wrote:

> Using NSTextView¹s native ability to embed image attachments, we have
> successfully implemented resizing of the image by using a resizable frame with
> a drag handle, and using setSize on the NSImage.  Works great.  Only one
> problem, re-archiving the NSAttributableString loses the image size change.
> Any way to fix this?  Internally, in a CoreData auxiliary file folder, we
> archive NSAttributableString.  Would we be better off storing it as RTFD?
> 
> I also see allusions to subclasses of NSTextAttachment, but I see no way to
> tell NSTextView, or its associates, to use such a subclass.
> NSTextAttachmentCell is a protocol.  But who adopts this protocol?  For an
> image, is this really a NSImageCell adopting this protocol?  Or is it the
> NSTextAttachment?  Confusion here.  Documentation on attachments is sparse.
> 
> We would also like to have the ability to set the baseline when an image is
> inserted, and change it when the image is resized.  Certain NSPDFImageReps
> contain baseline info in private dictionaries, which we would like to use,
> when available. In view of the above, should we abandon NSTextView¹s
> paste/drag-in capabilities for images and override all the relevant methods to
> do our own attachment inserts using a custom NSAttachment class?
> 
> Related question about NSImage.  I¹ve never understood setSize in NSImage.
> Does this just affect the cached image, or does it have any impact on the
> underlying imageRep, such as resizing and remapping a bitmap?
> 
> One more:  I¹ve never found a straightforward way to make a textView re-layout
> all or a portion of the text.  The best way I¹ve found is to call
> textContainerChangedGeometry.  Works, but seems rather obtuse.
> 
> Inquiring minds need to know.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to