• 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: Insert NSImage into NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Insert NSImage into NSTextView


  • Subject: Re: Insert NSImage into NSTextView
  • From: Jeremy Dronfield <email@hidden>
  • Date: Mon, 31 May 2004 21:02:09 +0100

On 31 May 2004, at 5:51 pm, Matt Ball wrote:
Although it does get
inserted, the app doesn't see the document as edited.

Methods which manipulate the text storage directly don't dirty the document. Try sending your text view a -didChangeText after you append your attributed string.

Secondly, and
this is probably a similar problem, the app will not let me drag the
image to other places in the textView to move it like I can with images
that have been dragged in. When I try to drag it, my Run window says:

-[NSTextView concludeDragOperation:]: Failed to read from drag
pasteboard. Drag operation failed.

I doubt if this will cure the problem, but it will simplify your code a little. Instead of creating an attachment cell and then adding it to your attachment, try this:

NSTextAttachment *attachment = [[NSTextAttachment alloc] init];

if ([(NSCell *)[attachment attachmentCell] respondsToSelector:@selector(setImage:)])
[(NSCell *)[attachment attachmentCell] setImage:[imageView image]];

The NSCell cast will prevent a compiler warning, since the NSCell method -setImage: isn't implemented in the NSTextAttachmentCell protocol.

My guess as to what's going wrong with dragging is that the image you're using is not a saved file. NSTextAttachment is set up to work with attached files (-initWithFileWrapper: is the designated initializer for NSTextAttachment). To get dragging to work with an image without a file wrapper, you'll probably need to write the image data to the pasteboard at the start of the drag operation.

Hope this helps. Regards,
-Jeremy
_______________________________________________
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.


References: 
 >Insert NSImage into NSTextView (From: Matt Ball <email@hidden>)

  • Prev by Date: Re: HElp with importing headers
  • Next by Date: Re: Window won't show a second time.
  • Previous by thread: Insert NSImage into NSTextView
  • Next by thread: NSImageView and Animated Gifs?
  • Index(es):
    • Date
    • Thread