RFR: 8313956: focusWithin on parents of a newly-added focused node is not updated [v2]

John Hendrikx jhendrikx at openjdk.org
Fri Aug 18 09:22:36 UTC 2023


On Fri, 18 Aug 2023 09:15:03 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> Michael Strauß has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Removed unnecessary code
>
> modules/javafx.graphics/src/main/java/javafx/scene/Node.java line 8201:
> 
>> 8199: 
>> 8200:         // Since focus changes are atomic, we only fire change notifications after
>> 8201:         // all changes are committed on all old and new parents.
> 
> Is it possible a user can interfere with this process by adding a listener to `focusWithinProperty`?  It fires events when it goes from `true` to `false` and vice versa.

I also noticed this code, which I think will not do the correct thing when `change` is not 1 or -1:

        void adjust(int change) {
            count += change;

            if (count == 1) {
                set(true);
            } else if (count == 0) {
                set(false);
            }
        }

For example, if focus within currently is `false`, and it is "adjusted" by 5, the count goes from 0 to 5 in one go.  It will remain `false` then.  Is this intended?

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

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


More information about the openjfx-dev mailing list