PTToolEvents
@protocol PTToolEvents <NSObject>
The PTToolEvents protocol allows the adopting class to receive events from a PTToolSwitching
and control the tool’s behavior.
-
Used by a tool to notify the tool manager that it has added an annotation.
Declaration
Parameters
toolThe tool that sent the message.
annotationThe annotation that was added.
pageNumberThe page number of the PDF that the annotation was added to.
-
Used by a tool to notify the tool manager that it has modified an annotation.
Declaration
Parameters
toolThe tool that sent the message.
annotationThe annotation that was modified.
pageNumberThe page number of the PDF that the annotation was modified on.
-
Used by a tool to notify the tool manager that it has removed an annotation.
Declaration
Parameters
toolThe tool that sent the message.
annotationThe annotation that was removed.
pageNumberThe page number of the PDF that the annotation was removed from.
-
Used by a tool to notify the tool manager that it has flattened an annotation.
Declaration
Parameters
toolThe tool that sent the message.
annotationThe annotation that was flattened.
pageNumberThe page number of the PDF that the annotation was flattened onto.
-
Used by a tool to notify the tool manager that it has modified the data of a form field.
Declaration
Parameters
toolThe tool that sent the message.
annotationThe form field annotation that has modified data.
pageNumberThe page number of the PDF that the form field annotation is on.
-
Allows the tool manager to take over link handling. Links can either be annotations, or detected as links by PDFNet via text pattern matching. One of the two first parameters will have a value, the other will be
nil.Declaration
Objective-C
- (BOOL)tool:(nonnull PTTool *)tool shouldHandleLinkAnnotation:(nullable PTAnnot *)annotation orLinkInfo:(nullable PTLinkInfo *)linkInfo onPageNumber:(unsigned long)pageNumber;Swift
func tool(_ tool: PTTool, shouldHandleLinkAnnotation annotation: PTAnnot?, orLinkInfo linkInfo: PTLinkInfo?, onPageNumber pageNumber: UInt) -> BoolParameters
toolThe tool that sent the message.
annotationThe link annotation, if it exists, that will be handled. If there is not a link annotation, then
nil.linkInfoIf it exists, the text that was detected as matching the format of a link.
nilotherwise.pageNumberThe page number that the annotation or link is on.
Return Value
YESif the tool should handle the link;NOif not. -
Allows the tool manager to control whether the tool should interact the given form annotation on
pageNumber.Declaration
Parameters
toolThe tool that sent the message.
annotationThe form annotation that will be activated
pageNumberThe page number that the annotation is on.
Return Value
YESif the tool should continue to select the annotation;NOif not. -
Allows the tool mananger to control whether the tool should handle the Apple Pencil Scribble interaction for a given annotation on
pageNumber.Declaration
Parameters
toolThe tool that sent the message.
scribbleInteractionthe scribble interaction.
annotationThe annotation that will be selected.
pageNumberThe page number that the annotation is on.
Return Value
YESif the tool should continue to scribble on the annotation;NOif not. -
Allows the tool manager to control whether the tool should select the given annotation on
pageNumber.Declaration
Parameters
toolThe tool that sent the message.
annotationThe annotation that will be selected
pageNumberThe page number that the annotation is on.
Return Value
YESif the tool should continue to select the annotation;NOif not. -
Used by a tool to notify the tool manager that it has selected an annotation.
Declaration
Parameters
toolThe tool that sent the message.
annotationThe annotation that was selected.
pageNumberThe page number that the annotation is on.
-
Used by a tool to notify the tool manager that text will be copied.
Declaration
Objective-C
- (nullable NSString *)tool:(nonnull PTTool *)tool willCopyReturnedText:(nullable NSString *)selectedText toPasteboard:(nonnull UIPasteboard *)pasteboard;Swift
func tool(_ tool: PTTool, willCopyReturnedText selectedText: String?, to pasteboard: UIPasteboard) -> String?Parameters
toolThe tool that sent the message
selectedTextThe text that will be copied
pasteboardThe pasteboard to which the text will be added
Return Value
The text that will be copied to the pasteboard. This may be different from the value of the
textToCopyparameter. -
Used by a tool to notify the tool manager that text was copied.
Declaration
Objective-C
- (void)tool:(nonnull PTTool *)tool didCopyText:(nullable NSString *)copiedText toPasteboard:(nonnull UIPasteboard *)pasteboard;Swift
func tool(_ tool: PTTool, didCopyText copiedText: String?, to pasteboard: UIPasteboard)Parameters
toolThe tool that sent the message
copiedTextAn in-out pointer to the text that was copied
pasteboardThe pasteboard to which the text was added
-
Allows the tool manager to control whether to show a menu controller for the given annotation and page number.
Declaration
Parameters
toolThe tool that sent the message.
menuControllerThe menu to be shown.
annotationThe annotation.
pageNumberThe page number that the annotation is on.
Return Value
YESif the tool should show the UIMenuController;NOif not. -
Allows the tool manager to control handling of file attachments.
Declaration
Objective-C
- (void)tool:(nonnull PTTool *)tool handleFileAttachment:(nonnull PTFileAttachment *)fileAttachment onPageNumber:(unsigned long)pageNumber;Swift
func tool(_ tool: PTTool, handle fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt)Parameters
toolThe tool that sent the message.
fileAttachmentThe file attachment annotation.
pageNumberThe page number that the annotation is on.
-
Allows the tool manager to control saving of file attachments.
Declaration
Objective-C
- (void)tool:(nonnull PTTool *)tool didAttemptFileAttachmentSave:(nonnull PTFileAttachment *)fileAttachment onPageNumber:(unsigned long)pageNumber success:(BOOL)success;Swift
func tool(_ tool: PTTool, didAttemptFileAttachmentSave fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt, success: Bool)Parameters
toolThe tool that sent the message.
fileAttachmentThe file attachment annotation to be saved.
pageNumberThe page number that the annotation is on.
-
Allows the tool manager to control handling of file selections.
Declaration
Objective-C
- (BOOL)tool:(nonnull PTTool *)tool handleFileSelected:(nonnull NSString *)filePath;Swift
func tool(_ tool: PTTool, handleFileSelected filePath: String) -> BoolParameters
toolthe tool that sent the message.
filePaththe selected file path
Return Value
YESif the selected file was handled,NOif not -
Allows the tool manager to control handling of file selections with destination page numbers.
Declaration
Objective-C
- (BOOL)tool:(nonnull PTTool *)tool handleFileSelected:(nonnull NSString *)filePath destinationPageNumber:(unsigned long)pageNumber;Swift
func tool(_ tool: PTTool, handleFileSelected filePath: String, destinationPageNumber pageNumber: UInt) -> BoolParameters
toolthe tool that sent the message.
filePaththe selected file path
pageNumberthe destination page number of the selected file
Return Value
YESif the selected file was handled,NOif not -
Allows the tool manager to control handling of named actions.
Declaration
Objective-C
- (BOOL)tool:(nonnull PTTool *)tool handleNamedAction:(nonnull NSString *)namedAction;Swift
func tool(_ tool: PTTool, handleNamedAction namedAction: String) -> BoolParameters
toolthe tool that sent the message.
namedActionthe namedAction
Return Value
YESif the named action was handled,NOif not -
Dispatches a “custom” event.
This method triggers an asynchronous call to
-[PTToolSwitching onSwitchToolEvent:]with the provided user data.Declaration
Objective-C
- (void)createSwitchToolEvent:(nullable id)userData;Swift
func createSwitchToolEvent(_ userData: Any?)Parameters
userDataArbitrary data provided by the tool.
-
Notifies the receiver that the live-appearance view will be displayed for the specified annotation.
Declaration
Parameters
toolThe tool sending this message.
appearanceViewThe annotation appearance view that will be displayed.
annotationThe annotation.
pageNumberThe page number of the annotation.
-
Notifies the receiver that the live-appearance view is no longer being displayed for the specified annotation.
Declaration
Parameters
toolThe tool sending this message.
appearanceViewThe annotation appearance view that was displayed.
annotationThe annotation.
pageNumberThe page number of the annotation.
PTToolEvents Protocol Reference