RFR: 8301121: RichTextArea Control (Incubator)

Andy Goryachev angorya at openjdk.org
Fri Aug 2 18:32:36 UTC 2024


On Fri, 2 Aug 2024 10:09:21 GMT, danielpeintner <duke at openjdk.org> wrote:

>> Thank you for a very good question!  
>> 
>> The main reason is that RichTextArea (RTA) can work with a large text model which needs to be represented differently from **TextInputControl**'s simple String **text** property.  Other things, like position within the text is also very different, using `{paragraphIndex,charOffset}` instead of a simple `int` offset.  The fact that the model is separated from the control also makes it very different.
>> 
>> At the end, there is simply no benefit in dragging the `TextInputControl` into the picture.
>
> I was hoping to be able to easily replace one (old) control with the _new_ one. I mean `RichTextArea` still fulfilling the requirements of `TextInputControl`. Anyhow, I understand you rational not going along this path 👍
> 
> Let me provide the use-case I have in mind (which may explain better what I am looking for).
> I would like to use/keep textfields and textareas with pure text. Anyhow, having the  possibility to _squiggly_ parts of the text showing spelling mistakes. Since I assume that loading many `RichTextArea` controls (i.e., in tables) will take much longer I expect to offer spelling suggestions (and `RichTextArea`  loading) on request only.

It looks like in this particular case you do want to preserve the semantics and APIs of TextArea, rather than switch to a new API.

You could simply extend TextArea/Skin and add functionality to superimpose the squiggly on top of TextArea.  You'll need to listen to several properties and make sure the clipping is set up correctly and you handle the scrolling et cetera, but I think it's doable.

Of course, once you decide that you need to further decorate your text, with let's say highlighted areas, then you might as well use the new component.

By the way, **CodeArea** is specifically designed for that purpose, even has `getText()` and `setText()` - but no textProperty because it's designed to work with large documents.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1702187490


More information about the openjfx-dev mailing list