This is a follow-up to last year's discussion on unconsumed event handlers:
https://mail.openjdk.org/pipermail/openjfx-dev/2024-November/050758.html

John correctly pointed out that last year's proposal was not entirely
consistent (discardUnconsumedEventHandlers() was still
order-dependent). Martin also cautioned that storing per-dispatch
state in Event instances can be brittle, because implementations might
not use Event.copyFor to derive event instances.

I've made two changes compared to the last proposal to address both concerns:

1. Event.discardUnconsumedEventHandlers() is replaced with
Event.preventDefault(). Calling this method at any time during event
dispatch causes default handlers not to be invoked.

2. Default handlers are not tracked in the Event instance, but as part
of the dispatch process.

Here is the PR with the proposed implementation:
https://github.com/openjdk/jfx/pull/2011

Andy preferred having explicit priorities. However, while default
handlers are conceptually quite simple (they are called in the order
they were registered, and you'll get the exact event as it existed
when the first-chance handler was called), a multi-dispatch
prioritized event system is conceptually more complicated. Currently,
events are ordered across phase x node-depth x event-type specificity.
Adding priorities would add another factor to this product, with
reverberations through the entire event system. In addition to that,
it would incentivize an arms race to higher priorities.

Reply via email to