Configuring Shortcut Buttons - Adonit/Adonit-iOS-SDK GitHub Wiki

To connect shortcut button presses to actions within your application, the first thing you need to do is to create a JotShortcut object. In the example below, a shortcut called Undo is created which is associated with an undo method within your application.

JotShortcut *undoShortcut = [[JotShortcut alloc] initWithDescriptiveText:@"Undo" key:@"undo" 
           target:self selector:@selector(undo)];

To assign this undo shortcut to the physical button number 1, simply do the following:

[[JotStylusManager sharedInstance] setButton1Shortcut:undoShortcut];

Similarly, if instead you wanted to assign it to physical button number 2:

[[JotStylusManager sharedInstance] setButton2Shortcut:undoShortcut];

If you want to make the undo shortcut available for the user to assign it to a button later:

[[JotStylusManager sharedInstance] addShortcutOption:undoShortcut];

Any shortcut added using this method can be retrieved later by using the shortcuts property on the JotStylusManager. If you want to add a shortcut to this list and assign it to a particular button at the same time, you can alternatively call either of the following methods depending on what button you want to assign a shortcut to:

[[JotStylusManager sharedInstance] addShortcutOptionButton1Default:undoShortcut];
[[JotStylusManager sharedInstance] addShortcutOptionButton2Default:undoShortcut];

As an alternative to using JotShortcuts, you can also add an observer to the default NSNotificationCenter for the following notifications.

  • JotStylusButton1Down
  • JotStylusButton1Up
  • JotStylusButton2Down
  • JotStylusButton2Up

Also consider using the Shortcut Button View Controller which allows a user to connect an action with a physical shortcut button.