Prioritized event handlers

John Hendrikx john.hendrikx at gmail.com
Tue Oct 24 08:47:33 UTC 2023


Looks very nice Michael, I especially like the more sane behavior with 
regards to consumed events.

I have a few questions on this:

- Would an event handler like KeyEvent.ANY at Preferred priority be 
called before one for KeyEvent.KEY_PRESSED at Default or System priority?

- The consumed flag doesn't change any other behavior? Consumed events 
only are passed to handlers at the same level, but are not bubbled up 
(or captured down); having consumed events not be passed to event 
handlers (even at the same level) seems like a more sane default for sure

- Is there a need for three levels?  If JavaFX behaves and adds it 
handlers at SYSTEM level, then I don't think there is a need for user 
handlers to have both DEFAULT and PREFERRED (they'd essentially do the 
same, as long as the user is aware in which order they are adding their 
own handlers).

- Is the order maintained within the various levels, ie, will the second 
PREFERRED handler added be called 2nd?

--John

On 24/10/2023 01:10, Michael Strauß wrote:
> Hi Andy!
>
> In a previous mail, I observed that a method like
> `BehaviorBase.addHandlerLast` suggests to me that we're lacking core
> tools in the JavaFX framework. In this case, we want to ensure that an
> event handler is always invoked before (or after) other event
> handlers.
>
> One way to do that might be to support prioritized event handlers at
> the core level, instead of creating new API that seems like a
> workaround. I've created a proof of concept for prioritized event
> handlers [0], which might be a moderate-effort but high-value addition
> to JavaFX.
>
> [0] https://github.com/openjdk/jfx/pull/1266


More information about the openjfx-dev mailing list