-
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
Is there anyway to have an inline css setstyle() for a StyleClassedTextArea or CodeArea please? #272
Comments
No. If you look at the code that applies the style to super(Collections.<String>emptyList(),
(paragraph, styleClasses) -> paragraph.getStyleClass().addAll(styleClasses),
Collections.<String>emptyList(),
(text, styleClasses) -> text.getStyleClass().addAll(styleClasses),
document, preserveStyle
); To get the result you want, you'd need to subclass (text, styleObj) -> styleObj.isStyleClass()
? text.getStyleClass().addAll(styleObj.toStyleClass())
: text.setStyle(styleObj.toCss()); |
@05dfleming (If by any chance you actually don't need style classes and only need inline CSS, then If you want a richer definition of "style" than just a set of style classes or just inline CSS, then neither As Jordan pointed out, you will need to use If you want to combine style classes and inline CSS, your "style" representation could be import org.reactfx.util.Tuple2;
import static org.reactfx.util.Tuples._;
StyledTextArea<Void, Tuple2<Collection<String>, String>> area = new StyledTextArea<>(
null, // initial paragraph style; not going to use it
(par, ps) -> { /* do nothing */ }, // function to apply paragraph style
t(Collections.<String>emptyList(), ""), // initial text style: no style classes and empty CSS string
(text, s) -> { // function to apply text style
text.getStyleClass().addAll(s._1); // apply style classes (first element of the style tuple)
text.setStyle(s._2); // apply inline CSS (second element of the style tuple)
}
); And then you can do Collection<String> styleClasses = ...;
String css = "-fx-fill: #00ff00 ;";
area.setStyle(0, 2, t(styleClasses, css)); |
I am so sorry to bother you about this, but just wondering if there was any way to set an inline css style such as area.setStyle(0,2, "-fx-fill: #00ff00 ; ") for a StyleClassedTextArea or CodeArea please? As I was hoping to have a way to take a colour from the fx colour picker then in real time then change the styles of certain words in code using that. But hoping to find an alternative to writing a few thousand colours in CSS to match the fx color picker :) As at the moment if I try that above, the colour just defaults to black. Any help would be massively appreciated, thanks :)
The text was updated successfully, but these errors were encountered: