gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: open recent in renaissance?


From: Tim Schmielau
Subject: Re: open recent in renaissance?
Date: Thu, 13 May 2010 23:55:05 +0100

On 13 May 2010, at 19:26, Wolfgang Lux wrote:

> Tim Schmielau wrote:
> 
>> Now I just have to figure out how to make those menu entries send openFile: 
>> messages...
> 
> You don't want to do that. The menu is managed by NSDocumentController, so 
> assuming that your application is document based, the document controller 
> will handle opening for you (just as if the user had selected the file via 
> the open panel). On the other hand, if your application is not document based 
> you are rolling on your own and should manage the whole menu yourself. The 
> fact that the menu may be populated for non-document based applications at 
> present is just an artifact of a (somewhat) poor implementation on my side, 
> which is subject to change.
> 
> Wolfgang
> 

My app is not document based. But that's just what Apple's documentation says 
for [NSDocumentController noteNewRecentDocumentURL:]

  "NSDocument automatically calls this method when appropriate for 
NSDocument-based applications. Applications not based onNSDocument must also 
implement the application:openFile: method in the application delegate to 
handle requests from the Open Recent menu command."

I can't at the moment find the Apple sample code where I derived this from. But 
my app does just these two things: 

  [[NSDocumentController sharedDocumentController] 
noteNewRecentDocumentURL:[NSURL fileURLWithPath: filename]]; to add entries to 
the recent documents menu,
  and implement - (BOOL)application:(NSApplication *)theApplication 
openFile:(NSString *)filename to open files.

It works flawlessly on OS X.

Tim







reply via email to

[Prev in Thread] Current Thread [Next in Thread]