mirror of
https://github.com/darlinghq/darling-cocotron.git
synced 2025-02-24 05:53:15 +00:00
Add fallback to open recent documents with NSApplicationDelegate methods
If a document can't be created when opening a recent document, the url points to a local file and the application delegate responds to application:openFiles: or application:openFile:, call them with the filename. This is the default behavior on Cocoa on Mac.
This commit is contained in:
parent
b5211d1744
commit
9ef2b1c8c3
@ -502,7 +502,16 @@ static NSDocumentController *shared=nil;
|
||||
NSError *error=nil;
|
||||
NSURL *url=[NSURL fileURLWithPath:[paths objectAtIndex:tag]];
|
||||
|
||||
[self openDocumentWithContentsOfURL:url display:YES error:&error];
|
||||
if (![self openDocumentWithContentsOfURL:url display:YES error:&error] || error) {
|
||||
if ([url isFileURL]) {
|
||||
NSObject <NSApplicationDelegate> *appDelegate = [NSApp delegate];
|
||||
if ([appDelegate respondsToSelector:@selector(application:openFiles:)]) {
|
||||
[appDelegate application:NSApp openFiles:[NSArray arrayWithObject:[url path]]];
|
||||
} else if ([appDelegate respondsToSelector:@selector(application:openFile:)]) {
|
||||
[appDelegate application:NSApp openFile:[url path]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user