PTToolManagerDelegate

@protocol PTToolManagerDelegate <NSObject>

The methods declared by the PTToolManagerDelegate protocol allow the adopting delegate to respond to messages from the PTToolManager class.

  • Allows the delegate to provide a view controller to manage presentations.

    Declaration

    Objective-C

    - (nonnull UIViewController *)viewControllerForToolManager:
        (nonnull PTToolManager *)toolManager;

    Swift

    func viewController(for toolManager: PTToolManager) -> UIViewController

    Parameters

    toolManager

    The Tool manager.

    Return Value

    a UIViewController provided by the delegate for the tool manager to use.

  • Allows the delegate to control if a tool should be activated

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        shouldSwitchToTool:(nonnull PTTool *)tool;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, shouldSwitchTo tool: PTTool) -> Bool

    Parameters

    toolManager

    The tool manager.

    tool

    The tool that will be activated

  • Tells the delegate that the tool will change.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        willSwitchToTool:(nullable PTTool *)tool;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, willSwitchTo tool: PTTool?)

    Parameters

    toolManager

    The tool manager

    tool

    The tool that will be activated.

  • Tells the delegate that the tool has changed.

    Declaration

    Objective-C

    - (void)toolManagerToolChanged:(nonnull PTToolManager *)toolManager;

    Swift

    optional func toolManagerToolChanged(_ toolManager: PTToolManager)

    Parameters

    toolManager

    The PTToolManager that had the tool change.

  • Allows the delegate to take over link handling. Links can either be annotations, or detected as links by PDFNet via text pattern matching (see -[PTPDFViewCtrl SetUrlExtraction:]). One of the two first parameters will have a value, the other will be nil.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        shouldHandleLinkAnnotation:(nullable PTAnnot *)annotation
                        orLinkInfo:(nullable PTLinkInfo *)linkInfo
                      onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, shouldHandleLinkAnnotation annotation: PTAnnot?, orLinkInfo linkInfo: PTLinkInfo?, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    toolManager

    The tool manager.

    annotation

    The link annotation, if it exists, that will be handled. If there is not a link annotation, then nil.

    linkInfo

    If it exists, the text that was detected as matching the format of a link. nil otherwise.

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should handle the link; NO if not.

  • Allows the delegate to control handling of file attachments.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        handleFileAttachment:(nonnull PTFileAttachment *)fileAttachment
                onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handle fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    the tool manager.

    fileAttachment

    the file attachment annotation

    pageNumber

    The page number that the annotation is on.

  • Allows the delegate to control saving of file attachments.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        didAttemptFileAttachmentSave:(nonnull PTFileAttachment *)fileAttachment
                        onPageNumber:(unsigned long)pageNumber
                             success:(BOOL)success;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, didAttemptFileAttachmentSave fileAttachment: PTFileAttachment, onPageNumber pageNumber: UInt, success: Bool)

    Parameters

    toolManager

    The tool manager sending the message

    fileAttachment

    The file attachment annotation to be saved

    pageNumber

    The page number that the annotation is on

  • Allows the delegate to control handling of file selections.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        handleFileSelected:(nonnull NSString *)filePath;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handleFileSelected filePath: String) -> Bool

    Parameters

    toolManager

    the tool manager.

    filePath

    the selected file path

    Return Value

    YES if the selected file was handled, NO if not.

  • Allows the delegate to control handling of file selections with destination page numbers.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
           handleFileSelected:(nonnull NSString *)filePath
        destinationPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handleFileSelected filePath: String, destinationPageNumber pageNumber: UInt) -> Bool

    Parameters

    toolManager

    the tool manager.

    filePath

    the selected file path

    pageNumber

    the destination page number of the selected file

    Return Value

    YES if the selected file was handled, NO if not.

  • Allows the tool manager to control handling of named actions.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        handleNamedAction:(nonnull NSString *)namedAction;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handleNamedAction namedAction: String) -> Bool

    Parameters

    toolManager

    the tool manager.

    namedAction

    the namedAction

    Return Value

    YES if the named action was handled, NO if not

  • Allows the delegate to control whether to show a menu controller for the given annotation and page number.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
         shouldShowMenu:(nonnull UIMenuController *)menuController
          forAnnotation:(nullable PTAnnot *)annotation
           onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, shouldShowMenu menuController: UIMenuController, forAnnotation annotation: PTAnnot?, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    toolManager

    The tool manager.

    menuController

    The menu to be shown.

    annotation

    The annotation.

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should show the UIMenuController; NO if not.

  • Allows the tool manager to control whether the tool should interact the given form annotation on pageNumber.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        shouldInteractWithForm:(nonnull PTAnnot *)annotation
                  onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, shouldInteractWithForm annotation: PTAnnot, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    toolManager

    The tool manager.

    annotation

    The form annotation that will be activated

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should continue to activate the form annotation; NO if not.

  • Allows the delegate to control whether the tool should handle the Apple Pencil (indirect) Scribble interaction for a given annotation on pageNumber.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        shouldHandleIndirectScribbleInteraction:
            (nonnull UIIndirectScribbleInteraction *)scribbleInteraction
                                  forAnnotation:(nonnull PTAnnot *)annotation
                                   onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, shouldHandle scribbleInteraction: __UIIndirectScribbleInteraction, forAnnotation annotation: PTAnnot, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    toolManager

    The tool manager.

    scribbleInteraction

    the indirect scribble interaction.

    annotation

    The annotation that will be selected.

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should continue to scribble on the annotation; NO if not.

  • Allows the delegate to control whether the tool should select the given annotation on pageNumber.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        shouldSelectAnnotation:(nonnull PTAnnot *)annotation
                  onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, shouldSelectAnnotation annotation: PTAnnot, onPageNumber pageNumber: UInt) -> Bool

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that will be selected.

    pageNumber

    The page number that the annotation is on.

    Return Value

    YES if the tool should continue to select the annotation; NO if not.

  • Raised when the tools code selects an annotation.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        didSelectAnnotation:(nonnull PTAnnot *)annotation
               onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, didSelectAnnotation annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that was selected.

    pageNumber

    The page number of the PDF that the annotation was selected on.

  • This method is called when text will be copied to the specified pasteboard.

    Declaration

    Objective-C

    - (nullable NSString *)toolManager:(nonnull PTToolManager *)toolManager
                  willCopyReturnedText:(nullable NSString *)selectedText
                          toPasteboard:(nonnull UIPasteboard *)pasteboard;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, willCopyReturnedText selectedText: String?, to pasteboard: UIPasteboard) -> String?

    Parameters

    toolManager

    The tool manager

    selectedText

    The text that will be copied

    pasteboard

    The pasteboard to which the text will be added

    Return Value

    The text that will be copied to the pasteboard. This return value may be different from the value of the textToCopy parameter.

  • This method is called when text has been copied to the specified pasteboard.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
            didCopyText:(nullable NSString *)copiedText
           toPasteboard:(nonnull UIPasteboard *)pasteboard;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, didCopyText copiedText: String?, to pasteboard: UIPasteboard)

    Parameters

    toolManager

    The tool manager sending the message

    copiedText

    The text that was added to the pasteboard

    pasteboard

    The pasteboard to which the text was added

  • Called when determining if the current user is permitted to edit an annotation made by a different author. If this method is not implemented then the current user is not permitted to edit the annotation.

    Note

    This method is only called when the PTToolManager.annotationAuthorCheckEnabled property is enabled.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        hasEditPermissionForAnnotation:(nonnull PTAnnot *)annotation
                            withAuthor:(nullable NSString *)author;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, hasEditPermissionForAnnotation annotation: PTAnnot, withAuthor author: String?) -> Bool

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that will be edited.

    author

    The author of this annotation.

    Return Value

    YES if the current user should be permitted to edit the annotation, NO otherwise.

  • Raised when the tools code adds an annotation

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        annotationAdded:(nonnull PTAnnot *)annotation
           onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, annotationAdded annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that was added.

    pageNumber

    The page number of the PDF that the annotation was added to.

  • Raised before the tools code modifies an annotation

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        willModifyAnnotation:(nonnull PTAnnot *)annotation
                onPageNumber:(int)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, willModifyAnnotation annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that will be modified.

    pageNumber

    The page number of the PDF that the annotation is on.

  • Raised when the tools code modifies an annotation

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        annotationModified:(nonnull PTAnnot *)annotation
              onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, annotationModified annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that was modified.

    pageNumber

    The page number of the PDF that the annotation is on.

  • Raised before the tools code removes an annotation

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        willRemoveAnnotation:(nonnull PTAnnot *)annotation
                onPageNumber:(int)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, willRemoveAnnotation annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that will be removed.

    pageNumber

    The page number of the PDF that the annotation will be removed from.

  • Raised when the tools code removes an annotation

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        annotationRemoved:(nonnull PTAnnot *)annotation
             onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, annotationRemoved annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that was removed.

    pageNumber

    The page number of the PDF that the annotation was removed from.

  • Raised before the tools code flattens an annotation. This will be called before the willRemoveAnnotation: delegate method.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        willFlattenAnnotation:(nonnull PTAnnot *)annotation
                 onPageNumber:(int)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, willFlattenAnnotation annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that will be flattened.

    pageNumber

    The page number of the PDF that the annotation will be flattened onto.

  • Raised when the tools code flattens an annotation. This will be called before the annotationRemoved: delegate method.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        annotationFlattened:(nonnull PTAnnot *)annotation
               onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, annotationFlattened annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    The tool manager.

    annotation

    The annotation that was flattened.

    pageNumber

    The page number of the PDF that the annotation was flattened onto.

  • Raised when the tools code modifies a form field annotation’s data

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        formFieldDataModified:(nonnull PTAnnot *)annotation
                 onPageNumber:(unsigned long)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, formFieldDataModified annotation: PTAnnot, onPageNumber pageNumber: UInt)

    Parameters

    toolManager

    The tool manager.

    annotation

    The form field annotation that has modified data.

    pageNumber

    The page number of the PDF that the form field annotation is on.

  • Raised when page has been added to the document.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        pageAddedForPageNumber:(int)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, pageAddedForPageNumber pageNumber: Int32)

    Parameters

    toolManager

    The tool manager.

    pageNumber

    The page number of the page that was added.

  • Raised when a page has been moved in the document.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        pageMovedFromPageNumber:(int)oldPageNumber
                   toPageNumber:(int)newPageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, pageMovedFromPageNumber oldPageNumber: Int32, toPageNumber newPageNumber: Int32)

    Parameters

    toolManager

    The tool manager.

    oldPageNumber

    The old page number of the page.

    newPageNumber

    The new page number of the page.

  • Raised when a page has been removed from the document.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        pageRemovedForPageNumber:(int)pageNumber;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, pageRemovedForPageNumber pageNumber: Int32)

    Parameters

    toolManager

    The tool manager.

    pageNumber

    The page number of the page that was removed.

  • Raised when pages will be rotated.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        willRotatePagesForPageNumbers:(nonnull NSIndexSet *)pageNumbers;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, willRotatePagesForPageNumbers pageNumbers: IndexSet)

    Parameters

    toolManager

    The tool manager.

    pageNumbers

    The page numbers of the pages that will be rotated.

  • Raised when pages have been rotated.

    Declaration

    Objective-C

    - (void)toolManager:(nonnull PTToolManager *)toolManager
        didRotatePagesForPageNumbers:(nonnull NSIndexSet *)pageNumbers;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, didRotatePagesForPageNumbers pageNumbers: IndexSet)

    Parameters

    toolManager

    The tool manager.

    pageNumbers

    The page numbers of the pages that were rotated

  • Allows the delegate to handle tap gestures.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
              handleTap:(nonnull UITapGestureRecognizer *)gestureRecognizer;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handleTap gestureRecognizer: UITapGestureRecognizer) -> Bool

    Parameters

    toolManager

    The Tool manager.

    gestureRecognizer

    The gesture recognizer that triggered the event.

    Return Value

    YES if the delegate has handled the event, NO if it should be handled by the tool manager.

  • Allows the delegate to handle double tap gestures.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        handleDoubleTap:(nonnull UITapGestureRecognizer *)gestureRecognizer;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handleDoubleTap gestureRecognizer: UITapGestureRecognizer) -> Bool

    Parameters

    toolManager

    The Tool manager.

    gestureRecognizer

    The gesture recognizer that triggered the event.

    Return Value

    YES if the delegate has handled the event, NO if it should be handled by the tool manager.

  • Allows the delegate to handle long press gestures.

    Declaration

    Objective-C

    - (BOOL)toolManager:(nonnull PTToolManager *)toolManager
        handleLongPress:(nonnull UILongPressGestureRecognizer *)gestureRecognizer;

    Swift

    optional func toolManager(_ toolManager: PTToolManager, handleLongPress gestureRecognizer: UILongPressGestureRecognizer) -> Bool

    Parameters

    toolManager

    The Tool manager.

    gestureRecognizer

    The gesture recognizer that triggered the event.

    Return Value

    YES if the delegate has handled the event, NO if it should be handled by the tool manager.