[jfx19] RFR: 8291502: Mouse or touch presses on a non-focusable region don't clear the focusVisible flag of the current focus owner [v3]

Kevin Rushforth kcr at openjdk.org
Mon Aug 1 22:27:03 UTC 2022


On Mon, 1 Aug 2022 18:42:46 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:

>> The `focusVisible` flag is only set on a node when it acquires input focus using a keyboard interaction, and it is cleared by mouse and touch interactions.
>> 
>> It is not necessary for a node to lose input focus in order to lose `focusVisible`. Currently, clicking on a region of the scene that does not contain a focusable node does not clear the `focusVisible` flag.
>> 
>> Detecting clicks or touches that should clear `focusVisible` can be achieved by adding an event filter for `MOUSE_PRESSED` and `TOUCH_PRESSED` to the `Scene`.
>> 
>> There is an additional noteworthy change with this PR:
>> Adding event filters to `Scene` causes many tests to fail due to a bug in `MouseEventFirer` that was identified in [8253769](https://bugs.openjdk.org/browse/JDK-8253769). Previously, mouse events generated by `MouseEventFirer` skipped a code path that causes test failures due to incorrect coordinates. With the added event filters, the code path for mouse events is slightly different, exposing the incorrect coordinates and causing tests to fail.
>> This problem can be solved by making the "alternative" `MouseEvent` generation path the default path.
>> 
>> Note: Since this is a follow-up fix for [8268225](https://bugs.openjdk.org/browse/JDK-8268225), I'm targeting this fix for `jfx19`.
>
> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
> 
>   null focus owner never has visible focus

This looks good, with a possible follow-up item to clarify the docs. I think it would be worth updating the spec to say that `focusVisible` is cleared on a `MOUSE_PRESSED` or `TOUCH_PRESSED` event (in addition to the other events that can clear it). I recommend doing this in a follow-up bug, so it doesn't derail getting this bug fix in.

Since this would be a doc-only change, it could be done during RDP2 of JavaFX 19 (or even deferred to JavaFX 20, but it seems best to shoot for 19). Either way, it will need a CSR.

-------------

Marked as reviewed by kcr (Lead).

PR: https://git.openjdk.org/jfx/pull/852


More information about the openjfx-dev mailing list