PTUndoRedoManager


@interface PTUndoRedoManager : NSObject <PTOverridable>

The PTUndoRedoManager class is responsible for managing the undo/redo chain of a PTPDFViewCtrl and an NSUndoManager instance.

  • Initializes a new PTUndoRedoManager instance with the given PDFViewCtrl.

    Declaration

    Objective-C

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

    Swift

    init(pdfViewCtrl: PTPDFViewCtrl)

    Parameters

    pdfViewCtrl

    the PDFViewCtrl

    Return Value

    an initialized PTUndoRedoManager instance

  • The PTPDFViewCtrl associated with the undo-redo manager.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) PTPDFViewCtrl *_Nonnull pdfViewCtrl;

    Swift

    var pdfViewCtrl: PTPDFViewCtrl { get }
  • Whether the undo-redo manager is enabled and updates the undo/redo state.

    When disabled (value is set to NO), the NSUndoManager owned by the pdfViewCtrl is cleared of all its actions and no new undo/redo changes will be registered.

    The default value of this property is YES.

    Note

    Change-snapshotting will still be performed on the pdfViewCtrl regardless of this property’s value. Other functionality, such as annotation change processing, relies on the information produced by change-snapshots.

    Note

    The value of this property is also derived from the PTPDFViewCtrl.isUndoRedoEnabled property of this undo-redo manager’s pdfViewCtrl.

    Declaration

    Objective-C

    @property (nonatomic, getter=isEnabled) BOOL enabled;

    Swift

    var isEnabled: Bool { get set }
  • Undo the last action.

    Declaration

    Objective-C

    - (void)undo;

    Swift

    func undo()
  • Redo the last undo.

    Declaration

    Objective-C

    - (void)redo;

    Swift

    func redo()
  • Creates a new state at the top of the undo/redo chain by taking a snapshot.

    Declaration

    Objective-C

    - (void)takeUndoSnapshot:(nonnull NSString *)actionInfo;

    Swift

    func takeUndoSnapshot(_ actionInfo: String)

    Parameters

    actionInfo

    meta-data to be attached to this new state.

  • Registers a generic change with the undo-redo manager.

    Declaration

    Objective-C

    - (void)registerChangeWithActionName:(nullable NSString *)actionName;

    Swift

    func registerChange(withActionName actionName: String?)

    Parameters

    actionName

    The name of the action

  • Undocumented

    Declaration

    Objective-C

    - (instancetype)init NS_UNAVAILABLE;
  • Used to notify the undo-redo manager that an annotation has been added.

    Declaration

    Objective-C

    - (void)annotationAdded:(nonnull PTAnnot *)annotation
               onPageNumber:(int)pageNumber;

    Swift

    func annotationAdded(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    annotation

    The annotation that was added.

    pageNumber

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

  • Used to notify the undo-redo manager that annotations have been added.

    Declaration

    Objective-C

    - (void)annotationsAdded:(nonnull NSArray<PTAnnot *> *)annotations
                onPageNumber:(int)pageNumber;

    Swift

    func annotationsAdded(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)

    Parameters

    annotations

    The annotations that were added.

    pageNumber

    The page number of the PDF that the annotations were added to.

  • Used to notify the undo-redo manager that an annotation has been modified

    Declaration

    Objective-C

    - (void)annotationModified:(nonnull PTAnnot *)annotation
                  onPageNumber:(int)pageNumber;

    Swift

    func annotationModified(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    annotation

    The annotation that was modified.

    pageNumber

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

  • Used to notify the undo-redo manager that annotations have been modified

    Declaration

    Objective-C

    - (void)annotationsModified:(nonnull NSArray<PTAnnot *> *)annotations
                   onPageNumber:(int)pageNumber;

    Swift

    func annotationsModified(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)

    Parameters

    annotations

    The annotations that were modified.

    pageNumber

    The page number of the PDF that the annotations were modified on.

  • Used to notify the undo-redo manager that an annotation has been removed.

    Declaration

    Objective-C

    - (void)annotationRemoved:(nonnull PTAnnot *)annotation
                 onPageNumber:(int)pageNumber;

    Swift

    func annotationRemoved(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    annotation

    The annotation that was removed.

    pageNumber

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

  • Used to notify the undo-redo manager that annotations have been removed.

    Declaration

    Objective-C

    - (void)annotationsRemoved:(nonnull NSArray<PTAnnot *> *)annotations
                  onPageNumber:(int)pageNumber;

    Swift

    func annotationsRemoved(_ annotations: [PTAnnot], onPageNumber pageNumber: Int32)

    Parameters

    annotations

    The annotations that were removed.

    pageNumber

    The page number of the PDF that the annotations were removed from.

  • Used to notify the undo-redo manager that the data of a form field has been modified.

    Declaration

    Objective-C

    - (void)formFieldDataModified:(nonnull PTAnnot *)annotation
                     onPageNumber:(int)pageNumber;

    Swift

    func formFieldDataModified(_ annotation: PTAnnot, onPageNumber pageNumber: Int32)

    Parameters

    annotation

    The form field annotation that has modified data.

    pageNumber

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

  • Used to notify the undo-redo manager manager that a page has been added.

    Declaration

    Objective-C

    - (void)pageAddedAtPageNumber:(int)pageNumber;

    Swift

    func pageAdded(atPageNumber pageNumber: Int32)

    Parameters

    pageNumber

    The page number of the page that was added.

  • Used to notify the undo-redo manager manager that a page has been moved.

    Declaration

    Objective-C

    - (void)pageMovedFromPageNumber:(int)oldPageNumber
                       toPageNumber:(int)newPageNumber;

    Swift

    func pageMoved(fromPageNumber oldPageNumber: Int32, toPageNumber newPageNumber: Int32)

    Parameters

    oldPageNumber

    The old page number of the page.

    newPageNumber

    The new page number of the page.

  • Used to notify the undo-redo manager that a page has been removed.

    Declaration

    Objective-C

    - (void)pageRemovedForPageNumber:(int)pageNumber;

    Swift

    func pageRemoved(forPageNumber pageNumber: Int32)

    Parameters

    pageNumber

    The page number of the page that was removed.

  • Used to notify the undo-redo manager that a page has been rotated.

    Declaration

    Objective-C

    - (void)pageRotatedForPageNumber:(int)pageNumber;

    Swift

    func pageRotated(forPageNumber pageNumber: Int32)

    Parameters

    pageNumber

    The page number of the page that was rotated.

  • Used to notify the undo-redo manager that pages have been rotated.

    Declaration

    Objective-C

    - (void)pagesRotatedForPageNumbers:(nonnull NSIndexSet *)pageNumbers;

    Swift

    func pagesRotated(forPageNumbers pageNumbers: IndexSet)

    Parameters

    pageNumbers

    The page numbers of the pages that were rotated.

  • Used to notify the undo-redo manager that a page’s content has changed.

    Declaration

    Objective-C

    - (void)pageContentModifiedOnPageNumber:(int)pageNumber;

    Swift

    func pageContentModified(onPageNumber pageNumber: Int32)

    Parameters

    pageNumber

    The page number of the page that had its content changed.