Skip to content
New issue

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

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

Already on GitHub? # to your account

TextFlow not displayed with formatting #3

Closed
adam-law opened this issue Jul 11, 2015 · 2 comments
Closed

TextFlow not displayed with formatting #3

adam-law opened this issue Jul 11, 2015 · 2 comments

Comments

@adam-law
Copy link

Hi,

Nice projects you've got here. I'm trying to use Flowless because using ListView + Textflow in Java 8u45 somehow makes the TextFlows on the list lose or change formatting when I add a new item. I'm not sure if I got the concept of TextFlow right, but I'm using a new instance for each item, because my ListView is meant to hold Nodes other than TextFlow e.g. WebView.

Anyway, I switched to test Flowless, because I was suspecting a layout issue with ListView, but I found that my TextFlows lose some formatting such as bold highlighting; though other stuff, like underline, still works.

The abstract class of my list item is just an extension of AnchorPane where I add the content after instantiation:

        // content is an arbitrary node
        AnchorPane.setTopAnchor(content, 0.0);
        AnchorPane.setBottomAnchor(content, 0.0);
        AnchorPane.setLeftAnchor(content, 0.0);
        AnchorPane.setRightAnchor(content, 0.0);

        getChildren().add(content);

Checking the TextFlow properties, everything seems as it should be:

[Text[text="Me:
", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Bold, family=System, style=Bold, size=14.0], fontSmoothingType=GRAY, underline, fill=0x000000ff], Text[text="test", x=0.0, y=0.0, alignment=LEFT, origin=BASELINE, boundsType=LOGICAL, font=Font[name=System Regular, family=System, style=Regular, size=15.0], fontSmoothingType=GRAY, fill=0x000000ff]]

Would you have any ideas on what's going on?

Thanks :)

Edit 1: Agh. Sorry for the bother, it seems the same issue is happening as in ListView, so it might be an issue with TextFlow itself? It seems the only time certain formatting becomes active or works, is if ALL children have the format e.g. bold.

Edit 2: I didn't know where to ask, but how do you force the VirtualFlow to scroll to the very bottom? ListView had the convenient scrollTo(index), but VirtualFlow doesn't have that. I've tried VirtualFlow.scrollY(Double.MAX) and VirtualFlow.show(index), but they work erratically.

@TomasMikula
Copy link
Member

Hi,

not sure what is going on in your case, but Flowless is used in RichTextFX, where every paragraph is a TextFlow, and bold font works there. If you think it is a TextFlow issue, you should come up with a simple self-contained example and report it to the JavaFX team.

show(index) should work to bring the specified item (e.g. the very last one) into the viewport. If it does not work for you, please open a separate issue for that, ideally with a minimal example demonstrating the issue.

@adam-law
Copy link
Author

Sigh. I figured there's a more complicated reason. It may the JFXtras window I use to host the message queue, who knows? :)

Thank you, by the way, for the quick reply. I'll go over your implementation of TextFlow with Flowless, for guidance.

show does work, sorry. I found that number I was passing was the erratic one; I used VirtualFlow.getChildrenUnmodifiable().size(). Passing my ObservableList size made everything alright.

On a side note, I really dig the Gravity attribute, and showing index 0 of my list, makes my output look better for my purposes.

All in all, a fine addition to my UI toolkit :)

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

No branches or pull requests

2 participants