This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
[dev feb 11, MDI, Linux, JDK 1.4.1_01] Alt-R does not work to post the Versioning menu. Generally, create a new menu named "He&llo". Alt-L does not post it. Rename it "&O Hello". Alt-O does work to post it. Suspect a problem in recently committed org.openide.awt.Mnemonics. Note that setLocalizedText2 creates a local var "ch" of type char. It then calls setMnemonic and *implicitly casts it* to int (already bad style). AbstractButton.setMnemonic (and JLabel.setDisplayedMnemonic) have two forms. One (apparently deprecated though no @deprecated) takes a char and I am guessing is case-insensitive. The other - the one Mnemonics calls - takes an int. (1) This is case-sensitive according to its documentation. (2) It is supposed to be a keycode! There is no necessary relation to a Unicode character. It so happens that KeyEvent defines VK_A .. VK_Z and VK0 .. VK9 to be their ASCII equivalents; this is not true of lowercase letters (which of course have the same keycode for purposes of mnemonics), nor for arbitrary other characters. In other words, Mnemonics.setMnemonic(Object,int) is written completely incorrectly. I am not sure offhand what needs to be done to fix it; you need to somehow take a Unicode char and translate it into the keycode which somehow might press to generate it, ignoring some modifiers like Shift. Source code for AbstractButton.setMnemonic(char) is of little use, since that only handles [A-Za-z] correctly, and I presume [0-9] too though that is not documented. However it seems that this method is only ever called with a char in the Latin range [A-Za-z0-9]. In that case the patch is simple: change the signature of Mnemonics.setMnemonic(Object,int) to be setMnemonic(Object,char). That should cause the older overload of AB.sM and JL.sDM to be called, which both correctly handle lowercase Latin letters (as well as uppercase Latin letters and apparently also Arabic digits and (char)0 for no mnemonic). Please try this one-line patch and see if it helps.
I suppose you are right - calling setMnemonic(int) is bad, I'll use setMnemonic(char) instead. Or, maybe, I should cut&paste a-z -> A-Z translation from setMnemonic(char) and call "not-obsolete" setMnemonic(int)? I'm also curious, what characters may be used as mnemonic other than [a-z,A-Z,0-9], maybe -,=,\,`,[,],;,',,,.,/ on some of them ([];',./` there're Russian letters).
Re. calling setMnemonic(char) vs. copying logic to translate [a-z] - I guess it doesn't make much difference. Re. other mnemonicable characters - don't know. I have only ever heard of alphanumerics as mnemonics. Since that is all the JRE supports, probably that is all we need to support too (besides your work - the special support for e.g. Alt-F posting an underlined Cyrillic phi).
Well, my final decision is not to copy [a-z] -> [A-Z] logic inside Mnemonics.java, but still I'd like to make some extensions to Mnemonics.java (no limit to improve ;-)): KeyEvent.VK_AMPERSAND!=(int)'&' !!!, hence I'll need to setup a table in Mnemonics.properties to convert '&' to KeyEvent.VK_AMPERSAND, and not just (int) it, i.e. MNEMONIC_&=150 I'll make a thorough test before commiting.
OK. Does anyone actually use '&' as a mnemonic? (Alt-Shift-7 on a US keyboard?) Just curious.
OK, wrong example ;-) VK_BACK_QUOTE != (int)'`' i.e.: MNEMONIC_`=192 Actually, I don't think that anybody will use ` as a mnemonics in English, but who knows... But there's a Russian character 'jo' (rarely used) on it, so MNEMONIC_\u0401=` would be wrong, the correct is MNEMONIC_\u0401=192
One more example: # public static final int VK_QUOTE 222 MNEMONIC_\'=222
done Checking in openide/src/org/openide/awt/Mnemonics.properties; new revision: 1.2; previous revision: 1.1 Checking in openide/src/org/openide/awt/Mnemonics.java; new revision: 1.2; previous revision: 1.1
Jesse, please verify, especially in English locale ;-)
Alt-R works now. Also I confirmed that ' and ` can work as mnemonics, for whatever that's worth.
More rewrite (now using setMnemonic(int) istead of setMnemonic(char)). Also under JDK1.3 when someone wants to set, e.g. `, as mnemonic a character that has a keycode different from a char itself, there's a conflict: appending (<Keycode>) shows some character, which is, hmm, a strange one ;-) (there's no such char on the keyboard), because <Keycode> is not a character at all. So, some mess is appended, but Alt+` will work. Under JDK1.4 everything is OK, but this is a A11Y issue on 1.3, so setting ` as mnemonic is HIGHLY not recommended, though possible.
Checking in openide/src/org/openide/awt/Mnemonics.java; new revision: 1.3; previous revision: 1.2 done, I hope ;-)