Bläddra i källkod

MacPDF: Make "Open With" and dropping files on dock tile work

I would've expected that there's some way to have this work
automatically in an NSDocument-based application, but I haven't
found it yet. So manually implement the delegate for now.
Nico Weber 1 år sedan
förälder
incheckning
ff4b0e678b
1 ändrade filer med 9 tillägg och 0 borttagningar
  1. 9 0
      Meta/Lagom/Contrib/MacPDF/AppDelegate.mm

+ 9 - 0
Meta/Lagom/Contrib/MacPDF/AppDelegate.mm

@@ -35,4 +35,13 @@
     return YES;
 }
 
+- (BOOL)application:(NSApplication*)sender openFile:(NSString*)filename
+{
+    [[NSDocumentController sharedDocumentController]
+        openDocumentWithContentsOfURL:[NSURL fileURLWithPath:filename]
+                              display:YES
+                    completionHandler:^(NSDocument*, BOOL, NSError*) {}];
+    return YES;
+}
+
 @end