On Wed, 23 Nov 2022 19:26:18 GMT, Andy Goryachev <ango...@openjdk.org> wrote:

>> This PR fixes a bug where multi-level focus is not correctly preserved.
>> The original implementation incorrectly assumed that there can only be a 
>> single focused node in the scene graph, which is not the case when a branch 
>> of the scene graph is presented by a `PopupWindow`. More specifically, when 
>> a focused node was removed from the scene graph, the focus flags of all 
>> parents were incorrectly cleared. The correct implementation only clears the 
>> `focusWithin` flag of parents (but not `focused` or `focusVisible`), and 
>> stops when another focused node is encountered along the way.
>
> modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 8196:
> 
>> 8194:         if (oldParent != null && focusWithin.get()) {
>> 8195:             Node node = oldParent;
>> 8196:             while (node != null && !node.focused.get()) {
> 
> is there a reason not to use isFocused() ?

In this area of the code, the eagerly initialized fields `focused`, 
`focusVisible` and `focusWithin` are used directly. Other than that, there's no 
reason. If you prefer the convenience getters, I can change it.

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

PR: https://git.openjdk.org/jfx/pull/956

Reply via email to