Insert NSImage into NSTextView
Insert NSImage into NSTextView
- Subject: Insert NSImage into NSTextView
- From: Matt Ball <email@hidden>
- Date: Mon, 31 May 2004 12:51:31 -0400
In my app, the user sets the specifications for a shape to be drawn to
an imageView using BezierPaths. When the user presses OK, the image is
inserted into the textView. The code i am using is:
NSTextAttachmentCell *attachmentCell = [[NSTextAttachmentCell alloc]
initImageCell:[imageView image]];
NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
[attachment setAttachmentCell: attachmentCell ];
NSAttributedString *attributedString = [NSAttributedString
attributedStringWithAttachment: attachment];
[[textView textStorage] appendAttributedString:attributedString];
This works well except for a few things. First, the app is not really
recognizing the image when it is inserted. Although it does get
inserted, the app doesn't see the document as edited. 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.
Does anyone have any possible solutions to my problems? Thanks.
-- Matt Ball
_______________________________________________
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.