JDK-8088025 : KeyCombinations for brackets and regular characters work differently
  • Type: Bug
  • Component: javafx
  • Sub-Component: scenegraph
  • Affected Version: 8u20
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • Submitted: 2014-05-28
  • Updated: 2024-10-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
KeyCombination.keyCombination(KeyCombination.SHORTCUT_DOWN + "+A") returns an instance of KeyCodeCombination.

KeyCombination.keyCombination(KeyCombination.SHORTCUT_DOWN + "+[") returns an instance of KeyCharacterCombination.

This causes accelerators processing to go through different code paths which can lead to various problems (e.g. see RT-37026).

Note that if I rewrite the last line as follows:

KeyCombination.keyCombination(KeyCombination.SHORTCUT_DOWN + "+Open Bracket")

then this will return an instance of KeyCodeCombination instead. This happens because the KeyCode class has a direct translation from the name "Open Bracket" to a corresponding key code, while the same translation for the "[" character is missing.

This seems odd in general. I don't expect developers to use "Open Bracket" when defining accelerators. Most likely they will use the "[" character directly. While in most cases they won't notice the difference in the behavior, it still doesn't look right somehow.

I suggest to evaluate:

1. Whether we can translate the "[" to its corresponding KeyCode directly. Note that other characters are affected by this issue as well (e.g. "]", etc.)

2. Whether we should support two ways to define the same thing. In this particular case a developer can create both the KeyCodeCombination and KeyCharacterCombination for the same key combination and seemingly same purposes. And it's not completely clear in which case the developer gets one or another, and why there should be two ways to express the same key combination. Perhaps this needs to be explained in the javadoc somewhere.