RFR: 8343956: Focus delegation API
John Hendrikx
jhendrikx at openjdk.org
Mon Jul 7 04:55:23 UTC 2025
On Tue, 11 Feb 2025 18:54:50 GMT, Martin Fox <mfox at openjdk.org> wrote:
> > I don't think the distinction quite holds. Scene does not delegate all key events. Menu shortcuts for example are consumed and never dispatched, and I think the same goes for mnemonics. Navigation keys are dispatched, and only acted upon by Scene when bubbled back up.
>
> What you describe is a common pattern in other UI toolkits but is not how JavaFX works. All key events are immediately fired at the Scene's focus owner and all processing happens within the resulting dispatch chain. The Scene provides a dispatcher that processes mnemonics during the capturing phase (early) and menu accelerators and navigation in the bubbling phase (late). The accelerators also cover the default dialog buttons.
But isn't that a distinction without a difference? Technically, you're right, all keys go to the focus owner. In practice though, some never make it out the door.
Looks like I recalled wrong how menu keys are processed, surprisingly they can be blocked if you want. I should have checked more closely :)
-------------
PR Comment: https://git.openjdk.org/jfx/pull/1632#issuecomment-2652253774
More information about the openjfx-dev
mailing list