The
Shortcut
class holds all the information necessary to load, represent, and activate a keyboard shortcut.
The most important and useful method here is the parseString
method, which is a "smarter" version of AWT's built-in KeyStroke.getKeyStroke(String s)
method. While they make you conform to their annoying formatting rules, this Shortcut class uses a few simplistic regular expressions to try and parse a string into a keyboard shortcut. Hopefully it works well for you!
Similar to the Action
class, you probably won't want to use the Shortcut
class on your own unless you're doing something advanced. Any Menu
object that allows keyboard shortcuts should provide a reasonable add()
or create()
method.
TODO: Add an isEnabled
field to the Shortcut
class, so that the user can disable and re-enable shortcuts as desired. The performAction
method should check this field to see whether it should perform the associated Action.
@author Greg
@see org.andrewberman.ui.Action
@see org.andrewberman.ui.ShortcutManager