-
Notifications
You must be signed in to change notification settings - Fork 236
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
request: add index range property to styled text #33
Comments
Hi Maher, thanks for asking, but this is not possible. The reason is that StyledTexts are moved around as text is inserted and deleted to and from text area. Imagine a text area with 1 million StyledTexts and insert one character at position 0. You would have to update all 1 million ranges. Another nice property about StyledTexts as they are is immutability. Immutability enables, for example, that the same StyledText instance can be in two different text areas at two different positions at the same time. |
Thanks! What is immutability?
|
Oh ok. Got it :)
|
Hi Tomas, I made a subclass of StyledText with range info, and a method to How about adding an index range property that only updates when it gets On Thu, Apr 10, 2014 at 2:14 PM, Maher Elkhaldi m.s.khaldi@gmail.comwrote:
|
Hi Maher, I don't think it's a good idea for StyledText to know its position within text area. What is your use case? Maybe we can come up with an alternative solution. |
Hi Tomas, For example: Maher (in bold) and sami (in normal). These technically two Now i want to increase the size of "er sa". This requires that u get the So i get the style from Maher, build a new one with a new size, then apply To do that, I made a method that rebuilds a collection if all styled texts This way I can apply specific styling parameters to any selection in text That was part of my question about how the data is structured and what Might be over engineered as a solution. But I am not a programmer.. More
|
You should do something like this: IndexRange range = area.getSelection();
StyleSpans<String> styles = area.getStyleSpans(range);
StyleSpans<String> newStyles = styles.mapStyles(css -> css + "-fx-font-size: 32pt;");
area.setStyleSpans(range.getStart(), newStyles); |
oh my God! On Thu, Apr 10, 2014 at 8:08 PM, TomasMikula notifications@github.comwrote:
|
Hi Tomas, Would it be possible to add an index range property to the styled text objects?
Maher
The text was updated successfully, but these errors were encountered: