PTToolSwitching

@protocol PTToolSwitching <PTPDFViewCtrlToolDelegate>

The PTToolSwitching protocol allows the adopting tool-class to specify the next tool to use if this tool does not completely handle an event.

  • The tool manager that is used as an interface for the PTToolManagerDelegate methods.

    Declaration

    Objective-C

    @property (nonatomic, weak) PTToolManager *_Nullable toolManager;

    Swift

    weak var toolManager: PTToolManager? { get set }
  • The annotation manager that is used to perform annotation-related operations.

    Declaration

    Objective-C

    @property (nonatomic, weak) PTAnnotationManager *_Nullable annotationManager;

    Swift

    weak var annotationManager: PTAnnotationManager? { get set }
  • A string that will be used to set the author field of annotations that are created.

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull annotationAuthor;

    Swift

    var annotationAuthor: String { get set }
  • Indicates if the tool can be used to create an annotation.

    The default value is NO.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL createsAnnotation;

    Swift

    var createsAnnotation: Bool { get }
  • The PTPDFViewCtrl that the tool or tool manager references.

    Declaration

    Objective-C

    @property (nonatomic, weak, readonly) PTPDFViewCtrl *_Nullable pdfViewCtrl;

    Swift

    weak var pdfViewCtrl: PTPDFViewCtrl? { get }
  • Returns a newly initialized tool with the required pointer to the PTPDFViewCtrl on which it will operate.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithPDFViewCtrl:
        (nonnull PTPDFViewCtrl *)pdfViewCtrl;

    Swift

    init(pdfViewCtrl: PTPDFViewCtrl)

    Parameters

    pdfViewCtrl

    a pointer to the PTPDFViewCtrl that the tool will operate.

    Return Value

    A newly initialized tool object.

  • Returns the next tool to use if this tool did not completely handle an event.

    Tools receive events, listed as the optional selectors in this protocol, from a PTPDFViewCtrl. If a tool does not finish handling an event (indicated by returning NO from one of the selectors that return a BOOL), then getNextTool is used to instantiate a new tool that will continuning handling the event.

    Declaration

    Objective-C

    - (nonnull instancetype)getNewTool;

    Swift

    func getNewTool() -> Self

    Return Value

    a newly instantiated UIView that conforms to the PTToolSwitching protocol.

  • Receives a “custom” event dispatched by -[PTToolManager createSwitchToolEvent:].

    This method gives the tool the opportunity to change to a new tool if it wishes to do so.

    Declaration

    Objective-C

    - (BOOL)onSwitchToolEvent:(nullable id)userData;

    Swift

    func onSwitchToolEvent(_ userData: Any?) -> Bool

    Parameters

    userData

    Arbitrary data provided by the tool.

    Return Value

    YES if the tool has handled the event, NO if it should be passed to a new tool of a different type.