|
@@ -15,7 +15,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
private var _annotations: [CPDFButtonWidgetAnnotation] = []
|
|
|
private var _formMode: CAnnotationType = .radioButton
|
|
|
var pdfView: CPDFListView?
|
|
|
- var annotationModel: CPDFAnnotationModel?
|
|
|
+ var _annotationModel: CPDFAnnotationModel?
|
|
|
|
|
|
@IBOutlet private weak var actionLabel: NSTextField!
|
|
|
@IBOutlet private weak var actionLabelTextField: NSTextField!
|
|
@@ -125,7 +125,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
|
|
|
func reloadData() {
|
|
|
if annotations.count > 0 {
|
|
|
- if annotation!.caption().isEmpty || annotation!.caption() == nil {
|
|
|
+ if annotation!.caption() == "" || annotation!.caption() == nil {
|
|
|
if let namedAction = annotation!.mouseUpAction() as? CPDFNamedAction {
|
|
|
actionLabelTextField.stringValue = NSLocalizedString("Print", comment: "")
|
|
|
} else if let urlAction = annotation!.mouseUpAction() as? CPDFURLAction {
|
|
@@ -163,7 +163,6 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
actionSendEmailTextField.isHidden = true
|
|
|
actionSendEmailLabel.isHidden = true
|
|
|
}
|
|
|
- } else {
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -186,7 +185,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
}
|
|
|
|
|
|
private func updateAnnotation() {
|
|
|
- if annotationModel?.annotation != nil {
|
|
|
+ if annotationModel.annotation != nil {
|
|
|
for tAnnotation in annotations {
|
|
|
tAnnotation.updateAppearanceStream()
|
|
|
pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
|
|
@@ -212,29 +211,21 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
set {
|
|
|
_formMode = newValue
|
|
|
self.isFromMode = true
|
|
|
-
|
|
|
- let sud = UserDefaults.standard
|
|
|
- var note: CPDFButtonWidgetAnnotation?
|
|
|
- let bounds = NSMakeRect(0, 0, 60, 25)
|
|
|
- var action: CPDFURLAction?
|
|
|
-
|
|
|
- if formMode == .actionButton {
|
|
|
- if let storedCaption = sud.string(forKey: SKAnnotationActionButtonWidgetCaptionKey) {
|
|
|
- note = CPDFButtonWidgetAnnotation(document: pdfView?.document, controlType: .pushButtonControl)
|
|
|
- }
|
|
|
-
|
|
|
- if let storedAction = sud.object(forKey: SKAnnotationActionButtonWidgetActionKey) as? CPDFURLAction {
|
|
|
-// action = storedAction
|
|
|
- note?.setMouseUpAction(action)
|
|
|
- } else if let storedActionName = sud.object(forKey: SKAnnotationActionButtonWidgetActionNameKey) as? CPDFNamedAction {
|
|
|
- note?.setMouseUpAction(storedActionName)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var annotationModel: CPDFAnnotationModel {
|
|
|
+ get {
|
|
|
+ return _annotationModel!
|
|
|
+ }
|
|
|
+ set {
|
|
|
+ _annotationModel = newValue
|
|
|
+ formMode = _annotationModel?.annotationType ?? .textField
|
|
|
+ if _annotationModel?.annotations != nil {
|
|
|
+ if annotationModel.annotations.count > 0 {
|
|
|
+ annotations = annotationModel.annotations as! [CPDFButtonWidgetAnnotation]
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- if let note1 = note {
|
|
|
- annotations = [note1]
|
|
|
- }
|
|
|
- annotation = note
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -295,7 +286,6 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
|
|
|
|
|
|
@objc func actionLabelTextFieldDidChange() {
|
|
|
for tAnnotation in annotations {
|
|
|
-// tAnnotation.removeAllAppearanceStreams()
|
|
|
tAnnotation.setCaption(actionLabelTextField.stringValue)
|
|
|
}
|
|
|
updateAnnotation() }
|