On Fri, 18 Aug 2023 21:12:58 GMT, Michael Strauß <mstra...@openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 8190:
>> 
>>> 8188:         Node node = oldParent;
>>> 8189:         while (node != null) {
>>> 8190:             node.focusWithin.adjust(-focusWithin.count);
>> 
>> suppose we are removing a Pane with a bunch of Nodes in it that have 
>> non-zero focusWithin.count values.
>> the parent of said Pane gets a zero count (which is correct), whereas the 
>> children of said Pane have their counts unchanged (I assume).
>> 
>> what happens when the same Pane gets added back to the scene graph?  
>> wouldn't we enter an inconsistent state?
>
>> suppose we are removing a Pane with a bunch of Nodes in it that have 
>> non-zero focusWithin.count values. the parent of said Pane gets a zero count 
>> (which is correct), whereas the children of said Pane have their counts 
>> unchanged (I assume).
> 
> Correct.
> 
>> what happens when the same Pane gets added back to the scene graph? wouldn't 
>> we enter an inconsistent state?
> 
> That's what this patch fixes. If we later add the pane that contains a number 
> of focused nodes back to the scene graph, the `focusWithin` count of its new 
> parents (which was 0 before) is now incremented to match the number of 
> contained focused nodes. The code starts in L8194.

thank you for explanations!

one more question: suppose, prior to removal of the Pane it contained a focused 
(Scene.focusOwner) Node.
1. once the Pane is removed, what happens to Scene.focusOwner?
2. once the Pane is added back, would we have an inconsistent state in respect 
to Scene.focusOwner (if some other node requested focus in the mean time, 
wouldn't we have two focused nodes?)

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1210#discussion_r1298876073

Reply via email to