< HelpSet fulltext-search index creationDocument file names >

Hotkeys

A nice snippet of code is the hotkeys generator for the menus. Since version 0.9.1, HelpSetMaker features keyboard shortcuts for the menu bars. These shortcuts are not manually defined, but a little generator creates them.

Mastermind for the hotkey generation is the QJCC class util.Hotkeys. Its main method is getHotkeys() which gets a list of Strings and returns a list of hotkeys, i.e. a unique character for each string which is contained somewhere in the string. Hotkeys uses a backtracking algorithm to generate such a list, however, this might be impossible. If so, a “best possible” list is returned which contains characters for as many strings as possible.

Hotkeys is feeded by biz.chitec.quarterback.swing.HotkeyManager, which is also contained in the QJCC. That class features a static method forMenuBar(), which gets the menubar and attaches all the hotkeys to the different entries.

These two classes together make the attachment of hotkeys to a complete menubar a one-liner. And, this might be the best feature, absolutely no manual preparation is needed for the attachment of the hotkeys.

< HelpSet fulltext-search index creationDocument file names >