<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Michael:</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Does the new approach fix <a href="https://bugs.openjdk.org/browse/JDK-8231245" data-outlook-id="22c21c7c-8b44-4f62-9e70-4e9e51734e17">
https://bugs.openjdk.org/browse/JDK-8231245</a> ?</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-andy</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div dir="ltr" style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="mail-editor-reference-message-container">
<div class="ms-outlook-mobile-reference-message skipProofing">
<meta name="Generator" content="Microsoft Exchange Server">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing" style="text-align: left; padding: 3pt 0in 0in; border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of Michael Strauß <michaelstrau2@gmail.com><br>
<b>Date: </b>Thursday, December 25, 2025 at 02:49<br>
<b>To: </b>openjfx-dev <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Re: Default event handlers<br>
<br>
</div>
<div class="PlainText" style="font-size: 11pt;">I've run into some problems while trying to make event handlers on<br>
skins only act when the event isn't consumed by user code. Consider a<br>
button that is nested in some hierarchy:<br>
<br>
scene<br>
--> root<br>
----> button<br>
<br>
When the button receives a MOUSE_RELEASED event, it consumes the event<br>
and fires off an ACTION event. Doing that in a default handler is<br>
fine, but as as consequence, the MOUSE_RELEASED event won't be<br>
immediately consumed. Instead, it bubbles up the entire hierarchy<br>
before it is finally handled and consumed by the button in its default<br>
handler after the dispatch chain has completed. This is clearly not<br>
what we want, as it can potentially cause ancestors to act on the<br>
event, too. (By the way, this also rules out an event system where<br>
events are dispatched in prioritized capture/bubble phases.)<br>
<br>
I think what we need is quite a bit simpler. Default event handlers<br>
are still the way to go, but they shouldn't act across the entire<br>
dispatch chain. Instead, they should only act locally on a single<br>
event target: when a target receives an event, it first invokes its<br>
regular handlers. Then, if the event is still eligible for default<br>
handling, the default handlers are invoked. Skins and behaviors should<br>
always use default handlers, never regular handlers.<br>
<br>
In the example, the button would consume the MOUSE_RELEASED event in<br>
its default handler, which will prevent it from bubbling up the<br>
hierarchy. If user code adds an event handler to the button, the user<br>
handler will always be invoked first and gets to decide whether to<br>
consume the event (Event.consume()), prevent the default handler from<br>
running (Event.preventDefault()), or let it continue to flow.<br>
<br>
Using this simplified model, I've been able to switch over InputMap<br>
and ListenerHelper (and therefore almost all controls) to use default<br>
handling, and it seems to work pretty well.<br>
<br>
Here is a PR with the implementation: <a href="https://github.com/openjdk/jfx/pull/2022" data-outlook-id="a920a7ac-3ce6-4ea9-9d6f-e676cabad04b">
https://github.com/openjdk/jfx/pull/2022</a><br>
</div>
</div>
</body>
</html>