Community
Participate
Working Groups
Build 20011122. In the edit menu for a Java editor, the accelerators for Shift Left/Right use Ctrl+I. Shouldn't it show as Ctrl+Tab? Tab should be a different keycode than CTRL+I. Currently, the Java editor takes both.
The short cut has history. First there was only CTRL-I then we added TAB (not CTRL-TAB) and SHIFT-TAB support as in VA/Java. Since short cuts are a limited resource, suggest to remove the CTRL-I and CTRL- SHIFT-I short cuts,
That would be my preference too.
Should the accelerator change to Tab, Shift-Tab or be left out completely?
Nick, Specifying 'Tab' and 'Shift-Tab' as accelerators in the properties file would let the menu items eat away the key events. Do you have a proposal for an unrecognized accelerator key name, as it's done with 'Delete'? 'Tabulation'/'Shift-Tabulation' looks weird...
In 2.0, you can specify both the accelerator text to display (using the normal @ syntax in the action label) and the -actual- accelerator to use (which may be different). In this case, specify "Shift Right@Tab" for the label and add an attribute: accelerator="0". See the extension point doc for more details. You can also specify accelerators using the string syntax (e.g. accelerator="Ctrl+Z", although this is currently undocumented (we're fixing it). See also Action.setAccelerator.
Well, I'm not using extension points. How can I programatically disable the accelerator? Calling Action.setAccelerator(0) does not help, as the accelerator will get overridden some time later when the label string is translated.
Do you mean in the future when translations are made for NLS, where they might not use Tab? Or do you mean in the current code, the label is set again later in the execution? If the former, wouldn't that pose a problem currently since you're hardwiring a key event to handle Tab? If the latter, please provide more details.
Also, it's reasonable to assume that NLS translations will use the same key. If you assume that all translations use Tab, then it's OK to reset the accelerator to 0 since you handle it in the key listener. If you don't want to do this, you can always check to see whether the accelerator is in fact Tab before resetting it.
The tabs are handled by key listeners. All I want is to change the menu item labels to present the right accelerator, w/o actually using them. The problem is that the accelerator get's overwritten with the accelerator provided in the label, even if I set it manually to 0 using setAccelerator(), since this seems to happen at a later time. A workaround is obviously to choose a name which would not actually translate to a real key accelerator. I thought for the same reasons 'Delete' was used instead of 'Del' in the edit menu.
Using a different word is just a hack, and is not recommended. When we did Delete, we didn't have setAccelerator. Action should probably be changed to allow either Del or Delete. If you're creating the action in code, then you control when the label is set. You should be able to just set the accelerator to 0 after setting the label. As long as you call setAccelerator(0) after setText(...), you should be fine.
fixed > 20020113