[External] : Re: RichTextArea Feedback

Jurgen Doll jurgen at ivoryemr.co.za
Tue Nov 4 12:21:34 UTC 2025


Hi Andy

> It is possible to add a Node to the content, but needs a custom model

Yes Node can be added (I've done that successfully with two different
models), but copy/paste and undo are impossible with current API.

> Also, what does it mean to copy a content with a Node, especially an
> interactive one, like a TextField?  This question cannot be answered
> generally, as it depends on the application requirements, thus the
> custom model.

Agreed. Actually, if I'm not mistaken, it depends on the available
DataFormatHandlers and not on the model itself. The model must just be
able to process all types of StyledSegment, which it currently doesn't.
The suggested API's are essential to accomplish this.

Then the developer must provide a custom DataFormatHandler to handle the
detail of what it means as per the application requirements.

Thanks, regards
Jurgen


On Nov 3 2025, at 8:31 pm, Andy Goryachev <andy.goryachev at oracle.com> wrote:

> Dear Jurgen:
>  
> It is possible to add a Node to the content, but needs a custom model
> (see SimpleViewOnlyStyledModel:488).
>  
> Also, what does it mean to copy a content with a Node, especially an
> interactive one, like a TextField?  This question cannot be answered
> generally, as it depends on the application requirements, thus the
> custom model.
>  
> Having said that, there might still be a need to provide the necessary
> protected APIs as you suggested.  I've added a note to https://bugs.openjdk.org/browse/JDK-8365948
>  
> Thanks!
> -andy
>  
>  
> From: Jurgen Doll <jurgen at ivoryemr.co.za>
> Date: Monday, November 3, 2025 at 01:53
> To: Andy Goryachev <andy.goryachev at oracle.com>
> Cc: openjfx-dev <openjfx-dev at openjdk.org>
> Subject: [External] : Re: RichTextArea Feedback
>  
> Hi Andy
>  
> Thanks for posting a summary to the dev list.
>  
> With regards to this point:
>  
>>> As expected though paste and undo/redo don't work due to
>> StyledTextModel's final replace method not handling INLINE_NODE's
>>  
>> This is correct, and I think it might be better to leave up to the
>> (custom) model.  The reason for it is it should be up to the
>> application/custom model to decide how to deal with the embedded
>> nodes, especially interactive ones.
>  
> I understand your rational, however having tried it myself (with two
> different models) I can claim with a high degree of confidence that it's
> currently impossible. Unless I've missed something, a developer
> extending any form of StyledTextModel cannot accomplish this.
>  
> The fix if I'm not mistaken is straightforward. What is required is
> the addition of something like the following method to StyledTextModel:
>  
> protected abstract int insertNodeSegment(int index, int offset,
> Supplier<Node> sup, StyleAttributeMap? attrs?);
>  
> and that the method:
>  
> public final TextPos replace(..., StyledInput input)
>  
> then handles INLINE_NODE and appropriately invokes this added
> insertNodeSegment method.
>  
> All your current sub-classes of StyledTextModel can then just implement
> No-Op implementations of insertNodeSegment. Of course it would be
> awesome if RichTextModel could handle inline nodes out of the box.
>  
> I hope this meets with your approval and if I've missed something please
> let me know.
>  
> Thanks, regards
> Jurgen


More information about the openjfx-dev mailing list