|
@@ -37,11 +37,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
super.viewDidLoad()
|
|
|
-
|
|
|
-// if let note = self.annotation as? CPDFButtonWidgetAnnotation {
|
|
|
-// note.controlType() = .pushButtonControl
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
actionLabel.stringValue = NSLocalizedString("Label", comment: "")
|
|
|
actionLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
|
|
@@ -114,34 +110,29 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
actionLabelTextField.layer?.backgroundColor = lightBackground
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
func reload() {
|
|
|
-// if let annotation = self.annotation as? PDFAnnotationButtonWidget {
|
|
|
-// annotation.widgetControlType = .widgetPushButtonControl
|
|
|
-// reloadData(annotation)
|
|
|
-// }
|
|
|
reloadData()
|
|
|
}
|
|
|
|
|
|
func reloadData() {
|
|
|
if annotations.count > 0 {
|
|
|
- if annotation!.caption() == "" || annotation!.caption() == nil {
|
|
|
- if let namedAction = annotation!.mouseUpAction() as? CPDFNamedAction {
|
|
|
+ if annotation?.caption() == "" || annotation?.caption() == nil {
|
|
|
+ if annotation?.action() is CPDFNamedAction {
|
|
|
actionLabelTextField.stringValue = NSLocalizedString("Print", comment: "")
|
|
|
- } else if let urlAction = annotation!.mouseUpAction() as? CPDFURLAction {
|
|
|
+ } else if annotation?.action() is CPDFURLAction {
|
|
|
actionLabelTextField.stringValue = NSLocalizedString("Submit", comment: "")
|
|
|
}
|
|
|
} else {
|
|
|
- actionLabelTextField.stringValue = (annotation!.caption())!
|
|
|
+ actionLabelTextField.stringValue = annotation?.caption() ?? ""
|
|
|
}
|
|
|
-
|
|
|
- if let urlAction = annotation!.mouseUpAction() as? CPDFURLAction {
|
|
|
+
|
|
|
+ if let urlAction = annotation?.action() as? CPDFURLAction {
|
|
|
actionSendEmailView.isHidden = false
|
|
|
- let actionUrlPath = urlAction.url().fileURL.absoluteString
|
|
|
-
|
|
|
+ let actionUrlPath = urlAction.url() ?? ""
|
|
|
actionSendEmailLabel.isHidden = false
|
|
|
actionSendEmailTextField.isHidden = false
|
|
|
-
|
|
|
+
|
|
|
if actionUrlPath.hasPrefix("http://") || actionUrlPath.hasPrefix("https://") {
|
|
|
actionSelectActionBtn.selectItem(at: 1)
|
|
|
actionSendEmailLabel.stringValue = NSLocalizedString("Add URL", comment: "")
|
|
@@ -166,24 +157,6 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- func updateAnnotationMode() {
|
|
|
- let userDefaults = UserDefaults.standard
|
|
|
- if formMode == .actionButton {
|
|
|
- userDefaults.set(annotation?.caption, forKey: SKAnnotationChoiceWidgetChoicesKey)
|
|
|
-
|
|
|
- if let mouseUpAction = annotation?.mouseUpAction {
|
|
|
- userDefaults.set(mouseUpAction, forKey: SKAnnotationActionButtonWidgetActionKey)
|
|
|
-
|
|
|
- if let actionURL = mouseUpAction as? PDFActionURL {
|
|
|
- let actionUrlPath = actionURL.url?.absoluteString ?? ""
|
|
|
- userDefaults.set(actionUrlPath, forKey: SKAnnotationActionButtonWidgetActionURLKey)
|
|
|
- } else {
|
|
|
- userDefaults.set(mouseUpAction, forKey: SKAnnotationActionButtonWidgetActionNameKey)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
private func updateAnnotation() {
|
|
|
if annotationModel.annotation != nil {
|
|
|
for tAnnotation in annotations {
|
|
@@ -286,9 +259,11 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
|
|
|
@objc func actionLabelTextFieldDidChange() {
|
|
|
for tAnnotation in annotations {
|
|
|
+ tAnnotation.updateAppearanceStream()
|
|
|
tAnnotation.setCaption(actionLabelTextField.stringValue)
|
|
|
+ self.pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
|
|
|
}
|
|
|
- updateAnnotation() }
|
|
|
+ }
|
|
|
|
|
|
@objc func actionSendEmailTextFieldDidChange() {
|
|
|
var url: String?
|
|
@@ -310,8 +285,8 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
for tAnnotation in annotations {
|
|
|
let action = CPDFURLAction(url: url)
|
|
|
tAnnotation.setMouseUpAction(action)
|
|
|
+ self.pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
|
|
|
}
|
|
|
- updateAnnotation()
|
|
|
}
|
|
|
|
|
|
@objc func themeChanged(_ notification: Notification) {
|