Keyboard Controls in RAP: Next Step Mnemonics

March 15, 2013 | 2 min Read

Applications built with RAP are often designed for high productivity: The faster you can control the app, the more work you can get done. In many cases, keyboard controls are significantly faster than mouse controls. Consequentially, RAP has continually improved keyboard controls since it’s inception.

What are Mnemonics?

Should you not know, Mnemonics are the characters that get underlined in some widgets (especially the menu bar) if you hold down the ALT key. Mac users may scratch their heads right now, because those aren’t supported in OS X. Their exact behavior differs a bit between the other platforms, but as long as you hold ALT and press of the underlined character on your keyboard, the widget gets selected. What I like about that is that, unlike normal shortcuts, you do not need to remember Mnemonics, and they can change all the time depending on what’s on screen.

Mnemonics in RAP 2.1M1

As of M2 (or the current nightly build), RAP will support Mnemonics on Menus, Buttons, ToolItems, TabItems, Labels and Groups. (Also CTabItem and CLabel.) To enable them, you first need to set the modifier that makes the Mnemonics visible. While you could use ALT, it’s strongly discouraged, because that would activate the actual Mnemonics of your browser with unpredictable results. I recommend using CTRL+ALT, and reserve CTRL and CTRL+SHIFT for global shortcuts/Key Bindings. The combo can be set with just one line:


Now all you need to do is to put a “&” before a character in a widgets text, and you already have a working Mnemonic. Example:

tabItem.setText( "Tab Item &1" );

Since this is a relatively complex new feature, I would love for developers to grab RAP 2.1M1 when it’s available next week and try it in their application so that we can get some feedback.

Coming soon: Full Accelerator support.