• 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: Best way to manage double-clicked files?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best way to manage double-clicked files?


  • Subject: Re: Best way to manage double-clicked files?
  • From: julius <email@hidden>
  • Date: Sat, 10 Dec 2011 15:23:48 +0000

On Fri, 09 Dec 2011 13:14:26 -0700 C.W. Betts wrote
>
> What is the best way to handle double-clicked files in an application that doesn't use documents? The reason I ask is because a project I'm working on, PCSX-R, currently uses NSDocument subclasses to handle opening of files double-clicked in the Finder. However, the readFromFileWrapper:ofType:error: function returns NO even if the file is loaded to prevent the document window from popping up (I have it se with no close buttons; the window is called modally), but it shows an error that the file wasn't opened, despite it being so.  Should I use a different way of managing double-clicked files, or is there a function that I should overload on my NSDocument subclass?
>
> ------------------------------
Hi,
not sure if understand your question.

I am assuming
1. you want program to start from double click of document file
2. you want to be able to open program by clicking application file but do not want the app to open an empty document window.

Create a document based application.
Create an application delegate file

//  MyApplicationDelegate.h
#import <Cocoa/Cocoa.h>
@interface MyApplicationDelegate : NSObject <NSApplicationDelegate> {
}
@end

//  MyApplicationDelegate.m
#import "MyApplicationDelegate.h"
@implementation MyApplicationDelegate
- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender {
	return NO;
} // end applicationShouldOpenUntitledFile
@end

In mainMenu.xib link the application's delegate outlet to MyApplicationDelegate
And that's it.

See bottom of this page
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Documents/Tasks/FAQ.html#//apple_ref/doc/uid/20000954-BAJDAFAB

also
http://www.cocoadev.com/index.pl?DocumentBasedAppOpenLastFileonStartup
and
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSApplicationDelegate_Protocol/Reference/Reference.html

Hope this helps.
Julius


http://juliuspaintings.co.uk



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Best way to manage double-clicked files?
      • From: "C.W. Betts" <email@hidden>
  • Prev by Date: Re: Locks
  • Next by Date: Re: How to initiate drag&drop for a filename outside of NSView mouseDown
  • Previous by thread: Best way to manage double-clicked files?
  • Next by thread: Re: Best way to manage double-clicked files?
  • Index(es):
    • Date
    • Thread