PSPDFStylusManager


@interface PSPDFStylusManager : NSObject

The stylus manager is the central point for pen/stylus management in PSPDFKit. - note: Drivers have to be linked externally, see the Extras folder in the PSPDFKit distribution. Compatible driver classes will be automatically detected at runtime. This class should not be instantiated manually but fetched from the PSPDFKit shared object.

  • If YES, sets applePencilEnabled to YES whenever PSPDFApplePencilDetectedNotification is posted, resulting in enabling Apple Pencil whenever a touch from one is detected. Defaults to YES.

    Setting this property does not directly set applePencilEnabled, so if you want to disable Apple Pencil and disable automatic enabling, you should set both properties to NO, and if you want to enable Apple Pencil immediately and re-enable automatic enabling, you should set both properties to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL automaticallyEnablesApplePencil;

    Swift

    var automaticallyEnablesApplePencil: Bool { get set }
  • Shortcut for whether currentDriverClass is PSPDFApplePencilDriver, and for setting the same. Setting this to NO disables any stylus.

    Declaration

    Objective-C

    @property (getter=isApplePencilEnabled, assign, readwrite, nonatomic)
        BOOL applePencilEnabled;

    Swift

    var isApplePencilEnabled: Bool { get set }
  • Set the current pen type. Disables internal SDKs and re-enables selected one.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic, nullable) Class<PSPDFStylusDriver>
        currentDriverClass;

    Swift

    var currentDriverClass: PSPDFStylusDriver.Type? { get set }
  • The current pen connection status.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFStylusConnectionStatus connectionStatus;

    Swift

    var connectionStatus: PSPDFStylusConnectionStatus { get }
  • Returns the name of the stylus, if possible. Will return Stylus if no name is returned by the driver.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *stylusName;

    Swift

    var stylusName: String? { get }
  • Available driver classes. Set classes for your supported stylus drivers. Stylues are presented in the order defined by this set. These must be set before creating PSPDFViewController. Defaults to only PSPDFApplePencilDriver. If you set this property and want to keep Apple Pencil support, you should include PSPDFApplePencilDriver in the set.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic)
        NSOrderedSet<Class<PSPDFStylusDriver>> *_Nonnull availableDriverClasses;

    Swift

    @NSCopying var availableDriverClasses: NSOrderedSet { get set }
  • Tries to restore last driver selection. Might load a driver and show the connection HUD.

    Declaration

    Objective-C

    - (BOOL)enableLastDriver;

    Swift

    func enableLastDriver() -> Bool
  • Returns a new instance of the stylus connector/chooser controller. - note: Will always return a controller, even if no drivers are available.

    Declaration

    Objective-C

    @property (readonly, nonatomic)
        PSPDFStylusViewController *_Nonnull stylusController;

    Swift

    var stylusController: PSPDFStylusViewController { get }
  • Native driver settings controller, if any.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable)
        UIViewController *settingsControllerForCurrentDriver;

    Swift

    var settingsControllerForCurrentDriver: NSViewController? { get }
  • Native driver settings controller size (if any)

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGSize embeddedSizeForSettingsController;

    Swift

    var embeddedSizeForSettingsController: CGSize { get }
  • Maps button numbers to actions, like undo or redo. - note: Keys are button numbers wrapped in NSNumber * and values are the following NSString * constants: - Undo: PSPDFStylusButtonActionUndo - Redo: PSPDFStylusButtonActionRedo - Ink: PSPDFStylusButtonActionInk - Eraser: PSPDFStylusButtonActionEraser

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        NSDictionary<NSNumber *, PSPDFStylusButtonAction>
            *_Nonnull buttonActionMapping;

    Swift

    var buttonActionMapping: [NSNumber : PSPDFStylusButtonAction] { get set }
  • Checks if driver does provide a settings controller.

    Declaration

    Objective-C

    - (BOOL)hasSettingsControllerForDriverClass:(nullable Class)driver;

    Swift

    func hasSettingsController(forDriverClass driver: AnyClass?) -> Bool
  • Register views that should receive pen touches.

    Declaration

    Objective-C

    - (void)registerView:(nonnull UIView *)view;

    Swift

    func registerView(_ view: Any!)
  • Deregister views that should receive pen touches.

    Declaration

    Objective-C

    - (void)unregisterView:(nonnull UIView *)view;

    Swift

    func unregisterView(_ view: Any!)
  • Touch classification, if supported by the driver.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL driverAllowsClassification;

    Swift

    var driverAllowsClassification: Bool { get }
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFStylusManager : NSObject
  • Whether a PSPDFStatusHUDItem should be shown when the connection status changes. Defaults to NO.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic)
        BOOL showsStatusHUDForConnectionStatusChanges;

    Swift

    var showsStatusHUDForConnectionStatusChanges: Bool { get set }