<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>There is also the focus traversable flag that interacts with
this, but perhaps there is a bug. When a button has
focusTraversable set to false, clicking it will not give it
focus. One may say that a property named "focus traversable"
would only affect focus *traversal* with the keyboard (as I'd
hardly call clicking with the mouse "traversal").<br>
<br>
That still leaves mnemonic short-cuts and default actions for
buttons though. Pretty sure those also don't focus the button and
aren't intended to, yet do execute the action.<br>
</p>
<p>--John<br>
</p>
<div class="moz-cite-prefix">On 15/10/2025 17:20, Andy Goryachev
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:DS0PR10MB727168540FF721701A34EFC8E5E8A@DS0PR10MB7271.namprd10.prod.outlook.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<ul
data-editing-info="{"applyListStyleFromLevel":false,"unorderedStyleType":4}"
style="margin-top: 0px; margin-bottom: 0px;">
<li
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 16px; color: rgb(0, 0, 0); list-style-type: "➢ ";">
<div dir="ltr" role="presentation"><span
style="background-color: rgb(255, 255, 255);">Buttons are
one of those (either with mouse press or keyboard short
cut)</span></div>
</li>
</ul>
<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);">
This looks like a bug to me, really. What is the main purpose
of the focus subsystem?</div>
<div dir="ltr"
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I know we like to reinvent the wheel, but focus in Swing works
as expected, and one does get focus lost event on mouse press,
and the target button gets the focus. Why should FX be
different?</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);">
-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 id="mail-editor-reference-message-container">
<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>John Hendrikx <a class="moz-txt-link-rfc2396E" href="mailto:john.hendrikx@gmail.com"><john.hendrikx@gmail.com></a><br>
<b>Date: </b>Wednesday, October 15, 2025 at 08:05<br>
<b>To: </b>Marius Hanl <a class="moz-txt-link-rfc2396E" href="mailto:mariushanl@web.de"><mariushanl@web.de></a>, Andy
Goryachev <a class="moz-txt-link-rfc2396E" href="mailto:andy.goryachev@oracle.com"><andy.goryachev@oracle.com></a>,
<a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a> <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>[External] : Re: Allowing a cell to commit
the value on focus loss<br>
<br>
</div>
<p class="ms-outlook-mobile-reference-message skipProofing">Hi
Marius,<br>
<br>
Focus lost is currently sort of a proxy of starting an
interaction with a new control, but not all controls gain
focus when interacted with. Buttons are one of those (either
with mouse press or keyboard short cut), but there is I think
also the scroll wheel that can interact with a control without
focusing it (and perhaps even popup menu's).<br>
<br>
I can only think of one half-baked solution to this:</p>
<p class="ms-outlook-mobile-reference-message skipProofing">-
Have a new Event type that is always targetted at the current
focus owner ("InterestLostEvent" ? :))<br>
- This event is automatically fired by Scene just before an
event is fired that is not targetted at the current focus
owner, AND the last event fired did have the focus owner as
target</p>
<p class="ms-outlook-mobile-reference-message skipProofing">What
would happen in practice then would be something like:</p>
<p class="ms-outlook-mobile-reference-message skipProofing">-
User edits field, keypress events go to current focus owner<br>
- User does something else (moves mouse, scrolls, presses a
hotkey, or presses a button):<br>
- An InterestLostEvent is fired at the current focus owner
BEFORE the new event is fired<br>
- The delayed new event is now fired<br>
- No further InterestLostEvents are fired until the focus
owner has received a normal event again<br>
- User goes back to editing after playing with the mouse;
events targetted at the focus owner renew the interest in that
control, and so next time an InterestLostEvent is fired again
when needed</p>
<p class="ms-outlook-mobile-reference-message skipProofing">It
feels a bit awkward, especially because simple things like
mouse moves may trigger it already (but a mouse move may
trigger something that requires the model to be up to
date...); perhaps it would need to be selective in some way so
one can choose to only be interested in the InterestLostEvent
on focus loss and mouse clicks.<br>
<br>
I can immediately see some problems as well. Some controls I
think allow editing without focus gain/loss at all (I think
some controls can be edited by just scrolling the mouse wheel
over them). When should those controls "commit" their
values...?</p>
<p class="ms-outlook-mobile-reference-message skipProofing">--John</p>
<p class="ms-outlook-mobile-reference-message skipProofing"><br>
</p>
<div class="moz-cite-prefix">On 15/10/2025 16:39, Marius Hanl
wrote:</div>
<blockquote>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
Hi John,</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
you are right that there might be corner cases. I hope that
we could, what Andy suggests, find all cases and have a
deeper look at them.</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
We can also check whether the focus delegation API from
Michael is something that could help us here (but might be
completely unrelated).</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
The other options as you also mentioned, also have their
problems. Even debouncing a commit on every keystroke can be
unreliable if the user is too fast.</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
I really hope we can make the focus loss reliable, as we
then do not need much of an API changes inside the Cell
Framework.</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
</div>
<div class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
-- Marius</div>
<div id="sub-body-container"
style="margin:10px 5px 5px 10px; padding:10px 0px 10px 10px; border-left:2px solid rgb(195,217,229)">
<div style="margin: 0px 0px 10px;">
<div><b>Gesendet: </b>Montag, 13. Oktober 2025 um 19:32</div>
<div><b>Von: </b>"Andy Goryachev" <a
href="mailto:andy.goryachev@oracle.com"
class="moz-txt-link-rfc2396E"
data-outlook-id="6c94a77a-2e53-4805-aa65-9ffa8fb3ebff"
moz-do-not-send="true">
<andy.goryachev@oracle.com></a></div>
<div><b>An: </b>"John Hendrikx" <a
href="mailto:john.hendrikx@gmail.com"
class="moz-txt-link-rfc2396E"
data-outlook-id="1e850900-45a9-4adc-83ba-f157728b2228"
moz-do-not-send="true">
<john.hendrikx@gmail.com></a>, <a
href="mailto:openjfx-dev@openjdk.org"
class="moz-txt-link-rfc2396E"
data-outlook-id="a27a8666-e9f2-46b8-8ffb-2d09a213df81"
moz-do-not-send="true">
"openjfx-dev@openjdk.org"</a> <a
href="mailto:openjfx-dev@openjdk.org"
class="moz-txt-link-rfc2396E"
data-outlook-id="b906db1f-880e-4264-86eb-d6ecc9d15732"
moz-do-not-send="true">
<openjfx-dev@openjdk.org></a></div>
<div><b>Betreff: </b>Re: Allowing a cell to commit the
value on focus loss</div>
</div>
<div
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I wonder if we should find out exactly why onFocusLost
does not work in these cases, as expected. Then, if I
understand the proposal correctly, we won't need any API
changes.</div>
<div
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<div
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
-andy</div>
<div
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<div
style="font-family: "Iosevka Fixed SS16", Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
</div>
<div id="mail-editor-reference-message-container">
<div
class="ms-outlook-mobile-reference-message skipProofing"> </div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="text-align: left; padding: 3pt 0in 0in; font-family: Aptos; font-size: 12pt; color: black;">
<b>From: </b>openjfx-dev <a
href="mailto:openjfx-dev-retn@openjdk.org"
class="moz-txt-link-rfc2396E"
data-outlook-id="0936a740-d8b1-48c6-9dcc-d151799b12d6"
moz-do-not-send="true">
<openjfx-dev-retn@openjdk.org></a> on behalf of
John Hendrikx <a href="mailto:john.hendrikx@gmail.com"
class="moz-txt-link-rfc2396E"
data-outlook-id="ce4e76f1-1c2e-4fa2-ac72-164dc8c89040"
moz-do-not-send="true">
<john.hendrikx@gmail.com></a><br>
<b>Date: </b>Monday, October 13, 2025 at 07:17<br>
<b>To: </b><a href="mailto:openjfx-dev@openjdk.org"
class="moz-txt-link-abbreviated moz-txt-link-freetext"
data-outlook-id="1071e77c-85ac-4e83-8bc7-be1d6708a3e1"
moz-do-not-send="true">openjfx-dev@openjdk.org</a>
<a href="mailto:openjfx-dev@openjdk.org"
class="moz-txt-link-rfc2396E"
data-outlook-id="923a556e-b054-467f-a4b1-5ad3ef93b826"
moz-do-not-send="true">
<openjfx-dev@openjdk.org></a><br>
<b>Subject: </b>Re: Allowing a cell to commit the value
on focus loss<br>
<br>
</div>
<p
class="ms-outlook-mobile-reference-message skipProofing">Hi
Marius,</p>
<p
class="ms-outlook-mobile-reference-message skipProofing">This
may be unrelated, but it may be problematic to rely on
committing values using focus lost:</p>
<p
class="ms-outlook-mobile-reference-message skipProofing">I've
built a lot of code that relies on focus lost to
"commit" values to some underlying model. However, I
noticed that a focus lost handler for committing values
is insufficient when an action is triggered that doesn't
trigger a loss of focus. For example, if I have a
field "email address" and a Button "Send Email", and I
have a focus lost handler to commit the email address
textfield to an underlying model, then pressing the
Button will not trigger that handler and the underlying
model may not have been updated with the latest edits.</p>
<p
class="ms-outlook-mobile-reference-message skipProofing">Solutions
to trigger the correct action are all a bit tricky or
annoying:</p>
<p
class="ms-outlook-mobile-reference-message skipProofing">-
Query all fields for their current contents as focus
lost is not entirely reliable for this purpose<br>
- Have fields update models immediately (which would be
on every key press...) -- this is not very efficient,
and can get in the way of validation / model
restrictions<br>
- Have controls listen to a "COMMIT" event (this is
fired at the current focus owner by the Button). This
event may be veto'd if committing the value resulted in
a validation error, in which case the button press is
cancelled</p>
<p
class="ms-outlook-mobile-reference-message skipProofing">I
don't like any of these, but using the last option at
the moment because I like constant updates and having to
requery UI components even less...</p>
<p
class="ms-outlook-mobile-reference-message skipProofing">--John</p>
<p
class="ms-outlook-mobile-reference-message skipProofing"><br>
I noticed however that if you edit some field (it
doesn't have to be in a table view, just a regular
field), and have a focus lost handler that commits the
value, that this focus lost handler is insufficient...</p>
<div class="moz-cite-prefix">On 13/10/2025 14:53, <a
href="mailto:mariushanl@web.de" target="_blank"
class="moz-txt-link-abbreviated moz-txt-link-freetext"
rel="noopener noreferrer"
data-outlook-id="211c3a65-8baf-48c1-a770-ed14e357499d"
moz-do-not-send="true">
mariushanl@web.de</a> wrote:</div>
<blockquote>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">All,</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"> </span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">I
created an initial poc 1* to support developers to
commit the cell value when the focus is lost 2*
(including 3*).</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">More
specifically, this gives the maximum flexibility to
choose what should happen when the focus is lost or
the editing index changed (which may happen when
clicking into another cell while editing).</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
All information mentioned here are also in the
description of the PR.</div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
</div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<b>API</b></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<b> </b></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">-
Instead of calling `<i>cancelEdit</i>`, every cell
now calls `<i>stopEdit</i>` when the focus is lost
or the editing index changed. The default behavior
is cancelling the edit, but developers can now
override the behavior and allow a `<i>commitEdit</i>`
instead<br>
- There are multiple 'events' that can lead to a
editing change. Every change will now call `<i>stopEdit</i>`.<br>
It is therefore the responsibility of the developer
to decide, when it makes sense to actually commit
the value instead of cancelling it. This decision
was made as the behavior is manipulating the editing
index, but you as a developer can as well. We do not
really know what intention led to e.g. a change of
the editing index.<br>
- Every `<i>MOUSE_PRESSED</i>` shifts the focus to
the cell container, which is undesired in case of
editing the cell. So this event is now consumed.<br>
- All `<i>TextField</i>` cells now commit their
value (instead of cancel) on focus loss<br>
- `<i>TextField</i>` Escape handling was badly
implemented (it was never really called, as the cell
container handled Escape before)</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"> </span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"><b>Considerations</b><br>
<br>
- I tried to make the API minimal, and without
breaking changes (other than the `<i>TextField</i>`
cells committing their values, but we may split this
up)<br>
- The Cell Container focus behavior is, well, weird
right now. That is why consuming the event is needed
to better support this PR. One thing we may can
consider is using the `<i>focusWithin</i>` property
instead for all 4 Cell Containers and not calling `<i>requestFocus</i>`
for nearly every `<i>MOUSE_PRESSED</i>` event. If we
decide so, this is needs to be done before merging
this PR.<br>
- Clicking the `<i>ScrollBar</i>` now
commits/cancels the edit. I checked other
applications and this is very common. But something
I need to note here. This probably can be fixed in
the same way mentioned above (`<i>focusWithin</i>`)</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">-
It might be hard for a developer to exactly know the
cause why `<i>stopEdit</i>` is called. This does not
seem like a problem, as e.g. for a `<i>TextField</i>`,
you normally register listeners for e.g. pressing
the Escape key on it, so you keep full control.</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"> </span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"><b>Another
Approach</b><br>
<br>
- Another Approach I tested could be to request the
focus to a cell when clicked/edited, to ensure that
the focus listener is ALWAYS called before another
cell will reach the editing state. Again, we
probably need to change the focus handling to e.g.
use the `<i>focusWithin</i>` property. With this
approach, we can only call `<i>stopEdit`
</i>when the focus changed (since it is now called
always), but not when the editing index changed.</span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"> </span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">1*
- <a
href="https://urldefense.com/v3/__https://github.com/openjdk/jfx/pull/1935__;!!ACWV5N9M2RV99hQ!KeaTwOLaODiie2jQZ01j-vH00U9_nZNV8YxV6B0SXCExWnLFky0svIofyVK0ZPt0xawAISlouP_NCkqvMwFhYVHnQZte$"
target="_blank" class="moz-txt-link-freetext"
rel="noopener noreferrer"
data-outlook-id="df2ae46c-bd31-4e46-8713-d2698d97bc79"
moz-do-not-send="true">
https://github.com/openjdk/jfx/pull/1935</a></span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">2*
- <a
href="https://bugs.openjdk.org/browse/JDK-8089514"
target="_blank" class="moz-txt-link-freetext"
rel="noopener noreferrer"
data-outlook-id="12c5818e-c660-4119-a032-680cda5e71f5"
moz-do-not-send="true">
https://bugs.openjdk.org/browse/JDK-8089514</a></span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">3*
- <a
href="https://bugs.openjdk.org/browse/JDK-8089311"
target="_blank" class="moz-txt-link-freetext"
rel="noopener noreferrer"
data-outlook-id="b80829ca-656b-4cd9-9728-ce9094150e86"
moz-do-not-send="true">
https://bugs.openjdk.org/browse/JDK-8089311</a></span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);"> </span></div>
<div
class="ms-outlook-mobile-reference-message skipProofing"
style="font-family: verdana; font-size: 12px; color: rgb(0, 0, 0);">
<span style="background-color: rgb(255, 255, 255);">--
Marius</span></div>
</blockquote>
</div>
</div>
</blockquote>
</div>
</blockquote>
</body>
</html>