Re: Quickest Way to Open an NSTextAttachment in NSTextView
Re: Quickest Way to Open an NSTextAttachment in NSTextView
- Subject: Re: Quickest Way to Open an NSTextAttachment in NSTextView
- From: "Kirt Cathey" <email@hidden>
- Date: Wed, 02 Mar 2005 06:51:50 +0000
Jeremy,
Thanks alot! I tried three different postings to this list all with a
different angle, then scoured to internet, other lists, and the apple
developer docs and got nothing. This answer solved my problem with about 15
minutes of programming. Just to help the next wayward Cocoa beginner, here
is the code.... if you see any memory leaks that I don't, please let me
know.
This brings up two more follow-up questions:
1) applications boot up just fine, but with larger files (35MB and above),
my program crashes. Is there a way to strengthen performance here?
2) Do I have to write once to the file system before opening the file as I
do in the code below? Or, is there a way to open directly from a
filewrapper?
Again, thanks for the help.
- (void)textView:(NSTextView *)textView clickedOnCell:(id
<NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame
atIndex:(unsigned)charIndex
{
NSTextAttachment *myAttachment = [[[NSTextAttachment alloc] init]
autorelease];
myAttachment = [cell attachment];
NSFileWrapper *myFileWrapper = [myAttachment fileWrapper];
NSData *myData = [myFileWrapper regularFileContents];
NSWorkspace *myWorkspace = [[NSWorkspace alloc]init];
NSFileManager *projectFile = [NSFileManager defaultManager];
NSMutableString *myPath = [[NSMutableString alloc]
initWithString:NSHomeDirectory()];
[myPath appendString:@"/WPData/temp/"];
[myPath appendString:[myFileWrapper preferredFilename]];
[projectFile createFileAtPath:myPath
contents:myData
attributes:nil];
BOOL WHAT;
WHAT = [myWorkspace openFile:myPath];
[myPath release];
[myWorkspace release];
[myAttachment release];
}
From the desk of ..........
Barking Frog
email: email@hidden
From: Jeremy Dronfield <email@hidden>
To: "Kirt Cathey" <email@hidden>
CC: email@hidden
Subject: Re: Quickest Way to Open an NSTextAttachment in NSTextView
Date: Sun, 27 Feb 2005 12:05:07 +0000
Implement the NSTextView delegate method:
- (void)textView:(NSTextView *)textView clickedOnCell:(id
<NSTextAttachmentCell>)cell inRect:(NSRect)cellFrame
atIndex:(unsigned)charIndex
Of course, this is called by a single click. You'll have to work on
setting it up to handle double clicks.
Regards,
-Jeremy
===================================
SkoobySoft, home of viJournal and Skooby Renamer
email: email@hidden or visit:
http://freespace.virgin.net/jeremy.dronfield/skoobysoft.html
===================================
On 27 Feb 2005, at 6:36 am, Kirt Cathey wrote:
Hi All.
Can anyone point me in the right direction on setting up my app so
that the user can double-click on an embedded file
(NSTextAttachment) and have the file open in a separate/associated
application?
From the desk of ..........
Barking Frog
email: email@hidden
_________________________________________________________________
辟。譁?250MB繝。繝シ繝ォ繝懊ャ繧ッ繧ケ縺ョMSN Hotmail
https://registernet.passport.net/reg.srf?id=2&lc=1041
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_________________________________________________________________
無料250MBメールボックスのMSN Hotmail
https://registernet.passport.net/reg.srf?id=2&lc=1041
_______________________________________________
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