On Thu, 8 Aug 2024 20:18:09 GMT, Martin Fox <m...@openjdk.org> wrote:

> For that matter you can't really infer that an event was consumed just 
> because the dispatch chain returned null. The EventDispatcher documentation 
> is a little hazy on this but in theory a dispatcher could return null for 
> other reasons. It seems to be mostly a matter of convention that null 
> indicates that an event was consumed.

It seems much more likely that we could clean this up by explicitly specifying 
this behavior.

Here's what I would do:
1. Implement [JDK-8303209](https://bugs.openjdk.org/browse/JDK-8303209)
2. Specify that `dispatchEvent` must only return `null` if the event was 
consumed.
3. Explicitly document that `Event.isConsumed()` can only be used inside of an 
event handler, but not to detect whether an event was consumed at the place 
where the event is fired.

This would be sufficient to solve the problem at hand, and will also enable 
third-party controls to do the same.

Going further, I question whether we need the `isConsumed()` method at all. 
Consumed events shouldn't be propagated, and the current behavior is very 
strange to say the least (events on the same level are propagated even though 
they're consumed). If consumed events are not propagated, there should be no 
need to check whether an event was consumed.

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

PR Comment: https://git.openjdk.org/jfx/pull/1523#issuecomment-2277066533

Reply via email to