RFR: 8343956: Focus delegation API
John Hendrikx
jhendrikx at openjdk.org
Fri Jul 11 10:16:49 UTC 2025
On Sat, 9 Nov 2024 01:28:53 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> Implementation of [focus delegation](https://gist.github.com/mstr2/44d94f0bd5b5c030e26a47103063aa29).
modules/javafx.graphics/src/main/java/com/sun/javafx/scene/DelegatingEventDispatcher.java line 57:
> 55: retarget = true;
> 56: event = event.copyFor(event.getSource(), delegate);
> 57: }
I think this improves the code by avoiding a reassignment:
Suggestion:
boolean retarget = event.getTarget() == parent;
// Focus delegation is the only scenario in which the event target may be the parent node.
// Since we are in the capturing phase, we need to retarget the event to the focus delegate.
if (retarget) {
event = event.copyFor(event.getSource(), delegate);
}
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1632#discussion_r2200139903
More information about the openjfx-dev
mailing list