File tree 4 files changed +32
-12
lines changed
4 files changed +32
-12
lines changed Original file line number Diff line number Diff line change 1
- //
2
- // AppDelegate.swift
3
- // Skewbacca Native
4
- //
5
- // Created by Antonio Radovcic on 01.01.19.
6
- // Copyright © 2019 niorad. All rights reserved.
7
- //
8
-
9
1
import Cocoa
10
2
11
3
@NSApplicationMain
12
4
class AppDelegate : NSObject , NSApplicationDelegate {
13
5
14
6
@IBOutlet weak var openMenuItem : NSMenuItem !
15
7
@IBOutlet weak var exportMenuItem : NSMenuItem !
8
+ var rootVC : ViewController !
9
+
10
+ func application( _ sender: NSApplication , openFile filename: String ) -> Bool {
11
+ rootVC. onFileDraggedOnDock ( filename)
12
+ return true
13
+ }
16
14
17
15
func applicationDidFinishLaunching( _ aNotification: Notification ) {
18
- // Insert code here to initialize your application
16
+ rootVC = ( NSApplication . shared . mainWindow ? . windowController ? . contentViewController as! ViewController )
19
17
}
20
18
21
19
func applicationWillTerminate( _ aNotification: Notification ) {
22
- // Insert code here to tear down your application
23
20
}
24
21
25
22
func applicationShouldTerminateAfterLastWindowClosed( _ sender: NSApplication ) -> Bool {
26
23
return true
27
24
}
28
25
29
-
30
26
}
31
27
Original file line number Diff line number Diff line change 4
4
<dict >
5
5
<key >CFBundleDevelopmentRegion </key >
6
6
<string >$(DEVELOPMENT_LANGUAGE) </string >
7
+ <key >CFBundleDocumentTypes </key >
8
+ <array >
9
+ <dict >
10
+ <key >CFBundleTypeExtensions </key >
11
+ <array >
12
+ <string >* </string >
13
+ </array >
14
+ <key >CFBundleTypeMIMETypes </key >
15
+ <array >
16
+ <string >image/jpeg </string >
17
+ </array >
18
+ <key >CFBundleTypeName </key >
19
+ <string >Image Files </string >
20
+ <key >CFBundleTypeRole </key >
21
+ <string >Viewer </string >
22
+ <key >LSTypeIsPackage </key >
23
+ <integer >0 </integer >
24
+ <key >NSDocumentClass </key >
25
+ <string >NSDocument </string >
26
+ </dict >
27
+ </array >
7
28
<key >CFBundleExecutable </key >
8
29
<string >$(EXECUTABLE_NAME) </string >
9
30
<key >CFBundleIconFile </key >
Original file line number Diff line number Diff line change 1
1
import Cocoa
2
2
3
-
4
3
class StageController : NSViewController {
5
4
6
5
@IBOutlet var topLeft : NSImageView !
Original file line number Diff line number Diff line change @@ -23,6 +23,10 @@ class ViewController: NSViewController {
23
23
}
24
24
}
25
25
26
+ func onFileDraggedOnDock( _ path: String ) {
27
+ stageViewController!. setImage ( URL ( fileURLWithPath: path) )
28
+ }
29
+
26
30
@IBAction func onOpenMenuItemSelected( _ sender: Any ) {
27
31
let openDialog = NSOpenPanel ( )
28
32
openDialog. title = " Open Image "
You can’t perform that action at this time.
0 commit comments