<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<div dir="ltr" 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 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 dir="ltr" class="ms-outlook-mobile-reference-message skipProofing"></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 John Hendrikx <john.hendrikx@gmail.com><br>
<b>Date: </b>Monday, October 13, 2025 at 07:17<br>
<b>To: </b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><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" class="moz-txt-link-abbreviated" data-outlook-id="659bf48c-5f83-409f-a765-12b99a998e56">
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://github.com/openjdk/jfx/pull/1935" target="_blank" class="moz-txt-link-freetext" rel="noopener noreferrer" data-outlook-id="66bd920f-85d9-4a16-ab91-3f14270b82bb">
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="be9029ff-01ce-4548-ab2d-ed85e4819064">
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="1cb1beee-3c13-4f60-bb2a-7e931e6002c5">
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>
</body>
</html>