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

Support embedding arbitary nodes like Hyperlinks and ImageView in text layout #355

Closed
sco0ter opened this issue Sep 8, 2016 · 4 comments

Comments

@sco0ter
Copy link

sco0ter commented Sep 8, 2016

Hi,

I need something similar to javafx.scene.text.TextFlow, where you can put HyperLinks and ImageViews as well (or any arbitrary Node), BUT unlike TextFlow, the Text (and maybe even HyperLinks) should be selectable (for copying the selected text).

Something like:
http://www.java-blog-buch.de/wp-content/uploads/2009/08/000073.png
(See the image on the bottom)

Think of a chat window with smileys and hyperlinks and probably other nodes embedded in the text layout.

It seems like Swing allows that (at least using images within text) using javax.swing.JTextPane + javax.swing.text.StyledDocument

I've looked at RichTextFX, but it seems you can only use plain text, but not embed other nodes in the text layout, right?

Anybody could point me in a direction, where to look and what to do, if I have to do it myself?

@JordanMartinez
Copy link
Contributor

Right. It only uses plain or rich text, but embedding other nodes is not currently supported (though I'm sure many want such a feature). You're not the first person to ask about inserting an arbitrary node. However, I think selecting it and copying/pasting it is a new request.

Have you already checked out #87? It's very similar to what you're requesting and Tomas has already stated something there.

@TomasMikula
Copy link
Member

Btw, you can have hyperlinks (since they can be just styled Text nodes with an onMouseClicked action), see #124 for an example.

Regarding arbitrary nodes, I would like to support that feature, but haven't thought too hard what would be the best way to implement it and (most importantly) what the API would look like.

Copying my comment from #314, which was @afester's take on custom objects:

Just a general remark: I am a big fan of type safety, so I would like to explore some generic approach that avoids runtime instanceof checks, or rules out the possibility (at compile time) that we get an object type that we don't know how to render.

@afester
Copy link
Collaborator

afester commented Sep 9, 2016

I have prepared a new iteration of my earlier proposal to support any custom node objects. It also supports copy&paste, but it does not yet support direct selection of custom nodes by clicking on them (but I already have that in mind). See #356 for the pull request.

@afester
Copy link
Collaborator

afester commented Jan 19, 2017

Fixed with #356. See the rich text editor demo how to add inline images. Hyperlinks require a little more work but should also be feasible now.

@afester afester closed this as completed Jan 19, 2017
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

4 participants