On Mon, 30 Jun 2025 17:10:46 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> The Mac platform code figures out where characters are on the keyboard as >> the user types. The character table is updated on every key press by calling >> a registerKeyEvent: in GlassApplication. This character table is used to >> resolve KeyCharacterCombination accelerators like Cmd + "+". >> >> On a US English layout when the user types Cmd + "+" on the main keyboard >> they're actually typing Cmd + "=". There's special handling in macOS for >> this combination that can cause two NSEvents to be sent and so there's >> special handling in the Glass code so we don't process both events. When >> this special case is invoked registerKeyEvent: isn't being called to update >> the character table. This bug was introduced when code was consolidated in >> PR #1528. >> >> The fix is a simple one-liner. I've added a test for this in the >> KeyboardTest.java program. It's an isolated test because it requires the >> Robot to send events to hold down a modifier while a character key is >> pressed. I also updated some obsolete comments and tweaked it to test all >> KeyCharacterCombinations since they should now work reliably on all >> platforms. > > tests/manual/events/KeyboardTest.java line 815: > >> 813: // OS special-cases this combination and so does JavaFX. In any case >> 814: // Shortcut + "+" is a very common shortcut and deserves a test. >> 815: private void testShiftedShortcut(Layout layout, Node focusNode, >> Logging log) { > > Question: is it possible to convert this manual test into an automated > headful one? I could write a weaker system test. The problem sequence is CMD + EQUALS. There are two possible outcomes depending on the keyboard layout; either the EQUALS yields nothing or it generates a PRESSED event that matches against KeyCharacterCombination("=", KeyCode.SHORTCUT_DOWN). It's not quite the same test but it would have caught this bug. I can verify that it would work on all the keyboard layouts that Apple ships with macOS 15. I'm less sure if the test would work cross-platform. It should but I don't have a good way of enumerating and testing all the layouts on Windows and Linux. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1837#discussion_r2175895293