Skip to content

Question: Is it possible to use RichTextFX as a backlog view in a chat application? #752

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

Closed
MrCustomizer opened this issue May 28, 2018 · 4 comments

Comments

@MrCustomizer
Copy link

Is it possible to use this library as the text display area of chat application? My chat application currently uses a web view and I would really like to replace it with something else. But I'm not sure yet, if this library is a good match. I hope you can help me.

I need the following features:

  1. Display images inline
  2. Display an avatar image in the first column (spanning multiple lines)
  3. Display a timestamp after every message
  4. Access and alter single messages (every message has a unique id)
  5. Add new messages before or after a specific message (again, this message would be identified by the unique id)
  6. Keep current scroll position when adding new or altering existing messages
  7. Listen to the scroll position, so fetching of older messages can be initiated, if the view is scrolled to the top
  8. Read only display, while text is selectable and copy and paste is supported

My analysis regarding RichTextFX so far:

  1. can be implemented with custom objects.
  2. is probably possible by using a paragraph graphic factory.
  3. is currently not possible
  4. could probably be implemented by keeping track of paragraphs or text positions in a separate data structure.
  5. same as 4.
  6. is directly supported by the library.
  7. could probably be implemented by using some listener functionality of the VirtualizedScrollPane.
  8. is directly supported by the library.

Is this analysis correct? Do you see other problems, which I have missed?

So if I'm not mistaken the biggest problem is number 3, as to my understanding the paragraph factory currently only can display nodes left to a paragraph. How hard would it be to extend the library with a new factory for placing nodes to the right side of a paragraph? Do you have ideas how this could be implemented in another way?

To get a clearer picture of what I'm talking about: Currently my backlog view looks like this (user avatars to the left, message in the middle, timestamp on the right; segment headers in between days):
image

@JordanMartinez
Copy link
Contributor

It sounds to me like you're trying to fit a square peg (RichTextFX) into a circle hole (your project goals).

If you're using RichTextFX (RTFX) for a user to type the message and hits send, then it makes sense to use RTFX.
However, if you're trying to use it to display everything in Arne's message (an avatar and the name, Arne, and richtext content spread across multiple lines, and a time stamp that corresponds to each message), it sounds like you will need to write your own custom components and integrate them together.

@MrCustomizer
Copy link
Author

Thank you for the fast response, I've feared as much. I think I will have a look at RichTextFX's internals and learn how text selection, VirtualFlow and TextFlow objects play together, so I can create my own custom chat view component.
Could you give me a pointer to a class where I should start? I'm guessing you internally have several TextFlow objects with one text object for every character, so text selection of individual characters can be made visible by changing the character's background color?

@MrCustomizer
Copy link
Author

Nevermind, I think I've found it. There is a virtual flow-object in the class GenericStyledArea. The paragraphs inside of it seem to be created by TextFlowObjects, which are an extension to JavaFX's TextFlow-class. I think I will find my way from here by myself.

Thanks again!

@JordanMartinez
Copy link
Contributor

Feel free to ask additional questions if you want more insight into the internals of this project.

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