Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make textflow selectable

I have made a TextFlow, as I need to use multiple font-postures (I have set particular "Text" to either italic or normal). Once I display the TextFlow, it's not selectable/copyable. All I need is the TextFlow to be selectable once it's displayed in a scene, so it can be copy/paste-able.

Text example with font-posture (only one for examples sake):

Text volumeText = new Text(volume.getText());
volumeText.setFill(Color.WHITE); 
volumeText.setFont(Font.font("arial", FontPosture.ITALIC, 13));
TextFlow reference = new TextFlow(
                         lastNameText, miscelanous1, firstNameText, miscelanous2);
reference.setLayoutX(115);
reference.setLayoutY(480);
reference.setMaxWidth(500);
control.getChildren().add(reference);
like image 704
RhysBuddy Avatar asked Mar 15 '23 09:03

RhysBuddy


1 Answers

Text and TextFlow in JavaFX are not "selectable".

There is an issue open for this : Text should have API for selecting group of characters based on their position similar to the DOM's Range.

Until the issue is taken care of, your best option is to use a 3rd party control like RichTextFX.

like image 157
ItachiUchiha Avatar answered Mar 24 '23 02:03

ItachiUchiha