X

Geertjan's Blog

  • October 16, 2011

Binding Mnemonics to Node Actions

Geertjan Wielenga
Product Manager

In yesterday's blog entry, you saw most/all Actions relevant to Nodes demonstrated within the context of a single sample:

However, what you do NOT see, in the screenshot above, are mnemonics.
In other words, maybe you'd like to let the user use a single character on the keyboard (which is not the same as a keyboard shortcut)
to invoke the various Actions shown above? If that support were
present, you'd see a character in the items above underlined, indicating
which key on the keyboard should be pressed to invoke the Action.

As luck would have it (or, in fact, as JDeveloper would have
it!), it is now possible (i.e., in 7.1 and onwards, already in 7.1 Beta
as well), to enable mnemonics in the above scenario.

This information should be no surprise to anyone who has read the NetBeans API Changes document, where you'll see this line:

(Jun 14 '11) org-openide-awt: Turn on Mnemonics in Popup Menus

As a result, you can change the sample to show mnemonics which,
when the underlined character is pressed on the keyboard, will cause the
underlying Action to be invoked:


Notice that the latter two Actions above appear not to have
mnemonics defined. (That's not a problem, just brand the display text, adding an ampersand before the character that you'd like to be the mnemonic.) I.e., the Action needs to define its own mnemonic
and, if it is defined, the mnemonic can now, for the first time, be
displayed and used to invoke the underlying Action.

Here's what you need to define to enable the mnemonic for the Actions of a Node:

Rather than creating the whole folder structure yourself, right-click the application, choose Branding, go to Resource Bundles, and then search for "USE_MNEMONICS". You'll then be able to brand the value right within the GUI, without needing to go into the folder/file structure you see above.

Join the discussion

Comments ( 1 )
  • Mvek Tuesday, February 7, 2012

    Sorry for a bit noob question, but can I change those menu entries (write there ampersand to have mnemonics)? I can do it in my custom action, but not in these, when I have no annotations.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.