Caret animation

Andy Goryachev andy.goryachev at oracle.com
Tue Jan 2 15:56:47 UTC 2024


I agree - this makes sense.

-andy


From: openjfx-dev <openjfx-dev-retn at openjdk.org> on behalf of John Hendrikx <john.hendrikx at gmail.com>
Date: Tuesday, December 26, 2023 at 21:54
To: openjfx-dev at openjdk.org <openjfx-dev at openjdk.org>
Subject: Caret animation

In light of a possible future Behavior API, I took a close look at the "complicated" behaviors surrounding TextFields and TextAreas.

One thing that came out of this is that caret animation is controlled by the behaviors by looking at key presses and keys typed. It is a very convoluted way of doing this as there is a much simpler rule that governs caret animation:

    when the caret moves, animation should be reset

This is how controls do it in browsers and on Windows, and it makes much more sense. The caret only needs highlighting when it actually changed position, and can remain animated when it doesn't.

This also means that caret blinking can simply be a concern of the Skin, as it can listen for caret position changes.  This also makes more sense.  Replacing the Behavior but keeping the same Skin should not break caret blinking.

Currently, the behaviors will wrap all possible key pressed/typed events to stop the blinking, but it gets it wrong in many situations (when the caret didn't actually move, or when a key press was not consumed or didn't do anything, or using keypad navigation which "forgets" to wrap it in the start/stop animation logic). It feels like a big hack when there is such an obvious alternative.

I've created this ticket to address this: https://bugs.openjdk.org/browse/JDK-8322748

One of the immediate benefits (aside from solving all caret animation bugs) is probably a memory reduction as it removes a wrapper around every key press/type mapping...

--John


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20240102/6a9ca44c/attachment-0001.htm>


More information about the openjfx-dev mailing list