Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding nodeFactory - custom Node implementation instead of TextExt #1178

Closed
cyfung1031 opened this issue Mar 10, 2023 · 5 comments

Comments

@cyfung1031
Copy link

cyfung1031 commented Mar 10, 2023

In GenericStyledArea, there is nodeFactory in its constructor.
For StyledTextArea, it creates TextExt which is extended from Text.

I tried many ways to make the fixed width for it, like setWrappingWidth, maxWidth + minWidth + prefWidth, still do not work.

I tried to modify the Text constructor's parameter to a padded text, the text width can be wider but looks like it breaks the layout of the text area. Some texts are visible but not selectable.

So I tried to make a container, like TextFlow, Pane, VBox, HBox, ... , the width can be fixed but the text are not selectable.

I just want to make a fixed width Text.
Might I ask how...? Thanks.

@Jugen
Copy link
Collaborator

Jugen commented Mar 10, 2023

Can you try and give a bit more detail as it's not clear if you want to have a fixed width font (i.e. Text), or if you want the text area to be fixed width (i.e. no wrapping), or do you mean that a paragraph may only be X characters wide and no more ?

@cyfung1031
Copy link
Author

cyfung1031 commented Mar 10, 2023

My texts are like

te8e77\tMy Word - Apple
x351\tMy Word - Orange
y991ww\tMy Word - Sun

As the text before \t is irrgular length, it will be ugly.
I want to make them all as the same width.

e.g.

te8e77              \tMy Word - Apple
x351                \tMy Word - Orange
y991ww              \tMy Word - Sun

I dont want to do modification to the text content. Just want to be visually good.

@cyfung1031
Copy link
Author

cyfung1031 commented Mar 11, 2023

It would be great if the TextFlow can be used as the Node produced by nodeFactory.

Right now there is no any way to support color emoji in RichTextFX.
Noto Fonts could not work with javafx. (but Noto Emoji can)
Only OpenSansEmoji can works but just mono color and the emoji set is very old. OpenSansEmoji will not update anymore I guess reason here.
( See: https://stackoverflow.com/questions/36854539/how-do-i-display-emoji-in-javafx-on-os-x )
(I found Noto Emoji afterwards. It works for javafx but just black and white. Noto Color Emoji seems not working)

[ this issue might related to javafx itself rather than RichTextFX, skip it for now ]

Therefore, I would like to have the answers regarding two things:

  • If I am creating the custom node instead of the default TextExt, what should my Node required to provide?
  1. The rendered text might not be the same length as the text provided. (e.g. I want to pad space or pad zero to the original text (the extracted text according setStyle & StyleSpan) )
  2. How to make my text in the custom node being selectable? Say I am using TextFlow or VBox to contain the Text node.

@cyfung1031 cyfung1031 changed the title Question regarding nodeFactory and Fixed Length Text Question regarding nodeFactory - custom Node implementation instead of TextExt Mar 11, 2023
@Jugen
Copy link
Collaborator

Jugen commented Mar 26, 2023

Sorry for the delayed response.

I think a possibly better way of solving your problem may be to have a look at the hyperlink demo.

I suggest modifying it so that instead of a hyperlink it returns a fix width Label that will then give the visual affect you are looking for, where you put the first part into the Label and the rest as normal text.

@cyfung1031
Copy link
Author

cyfung1031 commented Apr 24, 2023

Thanks for your response, although i did not try your demo.

I have switched to another way (use webview and javascript code mirror with css to solve the issue already)

Therefore this comment is closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants