<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Aptos;
panose-1:2 11 0 4 2 2 2 2 2 4;}
@font-face
{font-family:"Iosevka Fixed SS16";
panose-1:2 0 5 9 3 0 0 0 0 4;}
@font-face
{font-family:"Times New Roman \(Body CS\)";
panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:10.0pt;
font-family:"Aptos",sans-serif;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:"Iosevka Fixed SS16";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Michael:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Please help me understand.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">How does the idea of focus delegation works with multiple inner nodes that are supposed to handle different aspects of a complex control? For example, a custom combo box-like
control may contain an editor (possibly created dynamically), may be a couple of buttons, may be even two editors. How would that work?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">In this example, the buttons need focus to respond to ENTER or SPACE key presses, the editors should respond to key typed and maybe LEFT/RIGHT arrow keys to switch between
the two, and so on. Will the proposed design still work?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">If we presume the model in which the control is a monolithic entity, then we must accept the fact that there is a separate mechanism for the top level control to manipulate
its skin constituents. How it is done is not that important - events, or direct method calls, not important. Since we don't often have direct methods, using the events is probably the easiest.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">My point is that the mechanism of isolating the parts of skin from the usual event handling is **necessary**, especially when it comes to bubbling of events up the hierarchy.
Adding a bunch of methods trying to simulate that seems to be less optimal and more complicated.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">What do you think?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
<div id="mail-editor-reference-message-container">
<div>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of Michael Strauß <michaelstrau2@gmail.com><br>
<b>Date: </b>Monday, December 9, 2024 at 18:17<br>
<b>To: </b><br>
<b>Cc: </b>openjfx-dev <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Re: [External] : Re: Focus delegation API<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt">> Yep, this seems unnecessary and counterproductive to me. All we need is to drop the target field from the event.<br>
<br>
I can't image that we would ever do this, considering that events have<br>
been there almost from the beginning. We'd break half of the JavaFX<br>
world if we changed the API of events.<br>
In addition to that, this would remove functionality. As of now, you<br>
can add a listener to Scene, and inspect which node is being targeted<br>
by an event.<br>
<br>
<br>
> > 2. ComboBox's skin has installed an event filter on ComboBox<br>
><br>
> So we have another scenario where different priorities are needed: adding event filters.<br>
<br>
Maybe, but that's a different problem than what's being solved by<br>
focus delegation. Focus delegation is all about removing defective<br>
ad-hoc implementations, and offering a pre-made building block for<br>
composite controls.<br>
<br>
<br>
> > 3. However, it must forward the event to the TextField (as otherwise<br>
> the TextField doesn't work), so it fires off a copy of the event<br>
> targeted at TextField.<br>
><br>
> Maybe instead, there should be a way to send the event to a Node directly, without bubbling up. These internal events should never propagate outside of the skin's internals.<br>
<br>
Sure, that would be an option. But it's not my preferred solution for<br>
the following reasons:<br>
1. It's gratuitously different. Instead of using events like they<br>
normally work, control skins would punch a hole through the scene<br>
graph, and deliver the event directly to the delegation target. That<br>
means that the skin's scene graph works differently as the outside<br>
scene graph, as you can't observe events traveling through it.<br>
2. It requires the skin to implement a complex protocol (register an<br>
event handler, copy the event, punch a hole through to the delegation<br>
target, send off the event), whereas the focus delegation proposal<br>
requires no additional implementation inside of the skin (aside from<br>
selecting the delegation target).<br>
<br>
The advantage of focus delegation is that it just works, even<br>
recursively, across arbitrary levels of abstractions (a skin might<br>
contain another control, which itself has a skin, and so on). No<br>
matter where you listen to events, you will always see exactly what<br>
you'd expect to see: an event that is targeted at the next focused<br>
node. This is another aspect of focus delegation, unrelated to events:<br>
it formalizes the notion of multi-level focus without resorting to<br>
hacks (like FakeFocusTextField). You'll need to solve this no matter<br>
what, as users can click on the TextField. As we discussed, the<br>
ComboBox must be the focus owner even when a user clicks on the<br>
TextField.<br>
<br>
<br>
<br>
> Well, we don't need to add a bunch of weird properties for that (the first part). Just send the events to the skin's components directly, preventing the bubbling up part. There is no need for Event.target because there is no extraneous events being bubbled
up, and both CB and TF can process the events as they come in.<br>
<br>
First of all, it's only one property (Node.hoistFocus), not a bunch.<br>
And this is not related to events at all, it is a way for skins to<br>
indicate that clicking on an internal node will focus the outside<br>
control.<br>
<br>
The part of focus delegation that fixes the delivery of events in a<br>
scene graph with potentially nested abstractions is done without any<br>
new properties.<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>