On Tue, 30 Jul 2024 18:26:21 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

> Enable backpropagation of `isConsumed` flag to the ancestor(s) of events 
> cloned via `Event.copyFor()`.
> 
> This change has a minimal API impact and allows for a fine-grained control of 
> when to propagate and when not to propagate.
> 
> The proposed change could make 
> [JDK-8303209](https://bugs.openjdk.org/browse/JDK-8303209) unnecessary.

The cloning of an event is necessary in order to update the `target` when the 
event is fired and the `source` when the event is passed to a handler. The 
alternative would be to modify those fields in-place which sounds like a 
bookkeeping nightmare particularly if an event is re-fired (something this PR 
does). I can see why the JavaFX designers decided to make copies instead.

@andy-goryachev-oracle wrote:
> a) If the EventDispatcher does something different like creating the new 
> events, it is up to that ED to deal with consequences. It means the developer 
> wants to create new events and not to have the link between the events.

An EventDispatcher that creates a new event without linking it to the original 
will break this PR. But that's a consequence you're creating. You can't say the 
developer is making a choice about event linking when the very notion is new 
with this PR.

I agree with @mstr2, the dispatch machinery has an existing publicly accessible 
mechanism for communicating whether an event was consumed and it works fine. 
The documentation might be fuzzy around the edges but that can be solved.

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

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

Reply via email to