On Fri, 6 Nov 2026 18:45:08 GMT, yogi1967 <[email protected]> wrote: > **Symptom:** > On macOS, after selecting text in a Swing `JTextField` with the mouse from > right to left (including the first character, and releasing just past the > field's left edge), typing does not work normally. Each typed character > replaces the previous one, so the field only ever shows one character. > Clicking in the field clears the state. > > **Cause:** > On macOS, `nsToJavaModifiers` reads the current button state. If a > `MOUSE_DRAGGED` event is converted after the button is released, it has no > button modifier, so the mouse grab is dropped and `MOUSE_RELEASED` is > delivered to the wrong component. The text field never receives the > `MOUSE_RELEASED` event, so its `Autoscroller` continues re-applying the drag > selection which causes the condition where subsequently typed text appears > trapped in character one of the field in overtype mode. > > This issue has already been addressed by JetBrains in their JDK versions: > - JBR issue: [JBR-5762](https://youtrack.jetbrains.com/issue/JBR-5762) > - JBR fix commit: > [c3cf8bddea970e9ff413b0e7ad613ed003336b21](https://github.com/JetBrains/JetBrainsRuntime/commit/c3cf8bddea970e9ff413b0e7ad613ed003336b21) > - The current code file (refer Jbr5762Fix): > [CPlatformResponder.java](https://github.com/JetBrains/JetBrainsRuntime/blob/jbr25/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java) > > This PR/commit applies the same fix/logic as the JBR version (without JBR's > on/off system property). > > Testing: > - manual tests are problematic as it depends on system and EDT load, and race > conditions. I was able to reproduce with manual tests, but the bug reviewer > was not. > - automated `java.awt.Robot` tests don't trigger the condition > - however, I also tested the condition in our live java application where > it's easier to reproduce, the error occurred after 8 attempts > - applied this fix as patch to the same working java application and proved > that the issue did not occur (100 attempts), and that the fix properly caught > the trigger. > - requires `noreg-hard` label added to bug report by sponsor > - if required, I can upload the test file that intermittently works for me > > Further evidence: > - when running our live java app in debug mode within IntelliJ IDEA using JBR > JDK (and default parameters) the issue does not appear. > - When running with the JBR JDK but with their > `-Dawt.mac.enforceMouseModifiersForMouseDragged=false` setting to disable the > JBR fix, the issue is reproduced. > - I would offer that the JBR fix is already working and proven ...
FYI - the pre-submit run shown on this PR is stuck in "queued" on GitHub's side (the Windows tier1 failure was in common hotspot tests, and the macOS job never completed), and I don't seem to be able to cancel or do anything with them. I manually re-ran the Windows and macOS jobs on the same commit (66413c3) in my fork, and they all pass: - windows-x64 build + tier1: https://github.com/yogi1967/jdk/actions/runs/42374219389 - macos-aarch64 build + tier1: https://github.com/yogi1967/jdk/actions/runs/42371454661/attempts/2 The Linux, docs and windows-aarch64 jobs had already passed in the original run. ------------- PR Comment: https://git.openjdk.org/jdk/pull/33778#issuecomment-6719023906
