Re: Disabling Display of JPG and PDF Files in NSTextView
Re: Disabling Display of JPG and PDF Files in NSTextView
- Subject: Re: Disabling Display of JPG and PDF Files in NSTextView
- From: "Kirt Cathey" <email@hidden>
- Date: Wed, 14 Sep 2005 21:40:32 +0000
Doug,
First of all, thanks for helping out. Everything works without any changes
to the attachment cell, however, pdf and jpg do not appear as icons -- they
show up as opened images.
None of the text storage features are changed. Am just trying to store
those particular files as icons. Other files whose cells I do not change --
Word, Excel -- work great.
When I do:
[theAttachment setAttachmentCell:bCell];
as instructed below, then go back to open the file from the filewrapper
associated name with this code:
NSMutableString *myPath = [[[NSMutableString alloc]
initWithString:NSTemporaryDirectory()]autorelease];
[myPath appendString:[myFileWrapper filename]];
[projectFile createFileAtPath:myPath
contents:myData
attributes:nil];
which is executed from NSTextView's method
- (void)textView:(NSTextView *)textView clickedOnCell:(id
<NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame
atIndex:(unsigned)charIndex
I get the following error:
2005-09-15 06:22:48.624 WorkPapers[426] *** -[NSCFString appendString:]:
nil argument
The above happens without closing the document and re-opening. It happens
immediately after applying the attachment, then trying to open it.
HOWEVER, if I add:
[bCell setAttachment:theAttachment];
just below [theAttachment setAttachmentCell:bCell]; so it looks like:
[theAttachment setAttachmentCell:bCell];
[bCell setAttachment:theAttachment];
The attachment is placed as an icon and all works fine until the document
is closed. When the document is re-opened, the text attachment cell becomes
empty. I spent some time debugging why the appendString (in the code above)
is returning nil, and it is because the whole cell contents, are not
there... actually the cell with the icon image is there, but the
filewrapper is not.
So, my next questions are:
1) What do I have to do to create a complete NSTextAttachmentCell that gets
properly saved? I have three other text views within this same document and
I put them all through the same auto-save routine and all the others save
properly. Even the attachment window (this NSTextView) saves properly when
I do not change the cell for other documents besides jpg and pdf.
2) Every time I get deep into trying to solve this one -- fourth time now
-- I run into something called a glyph? I've Googled and all to only find
talk about a glyph, but cannot seem to figure it out. What is a glyph? Or,
should I not worry about it because it has nothing to do with my problem
here?
Regards,
-------------------------
Kirt S. Cathey
http://www.bizolutions.com
-------------------------
From: Douglas Davidson <email@hidden>
To: Kirt Cathey <email@hidden>
CC: email@hidden
Subject: Re: Disabling Display of JPG and PDF Files in NSTextView
Date: Wed, 14 Sep 2005 08:51:03 -0700
On Sep 13, 2005, at 2:24 PM, Kirt Cathey wrote:
NSTextView automatically displays JPG and PDF as images, instead of
icons, and while many people would be thrilled with this feature,
I don't want it. A posting from a while back fostered in getting
the code this far (this is raw without any checks or releases):
You should be able to do this by just letting NSTextView handle
attachments normally, but going through and locating any that you
don't want displayed as images, creating a new cell for each of
those, and calling setAttachmentCell: on the attachment. You don't
say how you are storing your text, but the attachment cell should
have no effect on the way the text is stored; that's all controlled
by the attachment. Does storing and loading of attachments work if
you don't try to prevent image display? If so, see what the
difference is in the stored files.
Douglas Davidson
_________________________________________________________________
無料でメールボックス250MBの 「MSN Hotmail」 http://messenger.msn.co.jp/
_______________________________________________
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