Browse Source

【合并】拖拽添加文档无效 -- 优化

lizhe 11 months ago
parent
commit
3bacc4e130

+ 17 - 3
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeBlankView/KMMergeBlankView.swift

@@ -7,13 +7,14 @@
 
 import Cocoa
 
-typealias KMMergeBlankViewDragAction = (_ view: KMMergeBlankView, _ fileNames: [URL]) -> Void
+typealias KMMergeBlankViewDragAction = (_ fileNames: [URL]) -> Void
 typealias KMMergeBlankViewMouseDownAction = (_ view: KMMergeBlankView) -> Void
 class KMMergeBlankView: KMBaseXibView {
     @IBOutlet weak var selectViewBox: KMBox!
     @IBOutlet weak var iconImageView: NSImageView!
     @IBOutlet weak var titleLable: NSTextField!
     @IBOutlet weak var subTitleLabel: NSTextField!
+    @IBOutlet weak var dragView: KMMergeBlankDragView!
     
     var dragAction: KMMergeBlankViewDragAction?
     var mouseDownAction: KMMergeBlankViewMouseDownAction?
@@ -52,11 +53,24 @@ class KMMergeBlankView: KMBaseXibView {
             }
         }
         
+//        registerForDraggedTypes([.fileURL])
+        
+        
+        dragView.dragAction = { [unowned self] urls in
+            self.dragAction?(urls)
+        }
+    }
+}
+
+class KMMergeBlankDragView: KMBaseXibView {
+    var dragAction: KMMergeBlankViewDragAction?
+    
+    override func setup() {
         registerForDraggedTypes([.fileURL])
     }
 }
 
-extension KMMergeBlankView {
+extension KMMergeBlankDragView {
     override func draggingExited(_ sender: NSDraggingInfo?) {
 
     }
@@ -118,7 +132,7 @@ extension KMMergeBlankView {
                     continue
                 }
             }
-            dragAction?(self, urls)
+            dragAction?(urls)
         }
         return true
     }

+ 12 - 4
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeBlankView/KMMergeBlankView.xib

@@ -1,13 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMMergeBlankView" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMMergeBlankView" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
+                <outlet property="dragView" destination="v66-gm-83Y" id="FIZ-Gy-PGQ"/>
                 <outlet property="iconImageView" destination="Q2N-Tf-H5f" id="Afs-uj-IHu"/>
                 <outlet property="selectViewBox" destination="aZk-BO-dft" id="ntu-eC-x7V"/>
                 <outlet property="subTitleLabel" destination="5Oj-UO-Lu1" id="juH-rI-6Pj"/>
@@ -39,7 +40,7 @@
                                 <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                             </textFieldCell>
                         </textField>
-                        <box boxType="custom" borderWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="aZk-BO-dft" customClass="KMBox" customModule="PDF_Master" customModuleProvider="target">
+                        <box boxType="custom" borderWidth="0.0" translatesAutoresizingMaskIntoConstraints="NO" id="aZk-BO-dft" customClass="KMBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
                             <rect key="frame" x="67" y="48" width="140" height="140"/>
                             <view key="contentView" id="b2K-9Q-f7v">
                                 <rect key="frame" x="0.0" y="0.0" width="140" height="140"/>
@@ -76,9 +77,16 @@
                         <constraint firstItem="aZk-BO-dft" firstAttribute="centerX" secondItem="VlN-ah-v0N" secondAttribute="centerX" id="oXH-RB-dfT"/>
                     </constraints>
                 </customView>
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="v66-gm-83Y" customClass="KMMergeBlankDragView" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                    <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+                </customView>
             </subviews>
             <constraints>
+                <constraint firstAttribute="bottom" secondItem="v66-gm-83Y" secondAttribute="bottom" id="UPw-rK-Frw"/>
                 <constraint firstItem="VlN-ah-v0N" firstAttribute="centerX" secondItem="c22-O7-iKe" secondAttribute="centerX" id="Xrx-dv-7k1"/>
+                <constraint firstItem="v66-gm-83Y" firstAttribute="top" secondItem="c22-O7-iKe" secondAttribute="top" id="bAL-px-6R7"/>
+                <constraint firstItem="v66-gm-83Y" firstAttribute="leading" secondItem="c22-O7-iKe" secondAttribute="leading" id="f19-Z8-bGZ"/>
+                <constraint firstAttribute="trailing" secondItem="v66-gm-83Y" secondAttribute="trailing" id="tDb-id-Lxx"/>
                 <constraint firstItem="VlN-ah-v0N" firstAttribute="centerY" secondItem="c22-O7-iKe" secondAttribute="centerY" id="zm0-x8-aD4"/>
             </constraints>
             <point key="canvasLocation" x="34" y="-72"/>

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift

@@ -83,7 +83,7 @@ class KMMergeView: KMBaseXibView {
         
         boxLabel.textColor = KMAppearance.Layout.h0Color()
         
-        blankView.dragAction = { [unowned self] view, filePaths in
+        blankView.dragAction = { [unowned self] filePaths in
             self.addFilePaths(urls: filePaths)
         }