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 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 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 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 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 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.

  • 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 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 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 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.

  • 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.