Really liking this approach.  Thank you for working on this!

I didn't have a comprehensive solution for handling external and internal focus yet, and only tried solving the event delegation problem.  This solution not only solves that, but also in such a way that 3rd parties can use the same solution in their custom controls.  It would be a solid addition to FX as closes the gap a bit between FX controls and custom controls.

There is one thing we may also want to consider (although probably not as part of this solution).  I was thinking that we still are mixing up filters/handlers of behaviors with user filters/handlers.  The order of these can change depending on what is installed first, or when Skins are exchanged.  But if Control had a custom event dispatcher, it could pretty easily place the filters/handlers of Behaviors somewhere else.  For events handled that would mean there's an additional level in the event dispatch chain, instead of:

    Window -> Scene -> Node -> Control -> Internals

It would become

    Window -> Scene -> Node -> Control -> Behavior filter/handlers -> Internals

As Behaviors would have their own separate filter/handler lists, there can never be interference with user handlers, and the order in which events are handled will always be the same.  It could also make installing/uninstalling behaviors easier, as you can just throw away all filter/handlers installed on the special Behavior filter/handler lists when a behavior is replaced.

--John

On 09/11/2024 02:33, Michael Strauß wrote:
Hi everyone,

here is a proposal to finally solve the focus delegation problem that
has recently been discussed in the "Prioritized event handlers"
thread.

Proposal: https://gist.github.com/mstr2/44d94f0bd5b5c030e26a47103063aa29
Draft PR: https://github.com/openjdk/jfx/pull/1632

Reply via email to