I have a text field and I'm able to change the text size of a Text node no problem with
Text text = new Text();
text.setStyle("-fx-font-size: 16;");
but if I try to change the colour, nothing works:
textStart.setStyle("-fx-font-size: 16;-fx-color: #ff0000;-fx-text-base-color: #ff0000;-fx-text-fill: #ff0000;");
I find in JavaFX every node seems to need a different css command to successfully change the colour, but with Text, none of them seem to work. I can change the text with
text.setFill(Color.RED);
But it's awkward to have two separate commands on separate lines when it should be able to be done in one line of css. Especially since what I'm doing is relatively heavy processing of many lines of text.
Does anyone know what the css command to change the colour is with a Text node? Seems so odd it only accepts the size command in css..
Related
I prepare a document in Markdown in which I have to highlight changes in color. I am aware that I could wrap the text like this:
This text is unchanged, however \textcolor{red}{I changed this}, before going back to the original color.
But I would prefer to define my own command, similar to the **<this is bold text>** solution, without all the brackets. I found the following solution to make all bold text also blue, but since I am new to latex I have been unsuccessful trying to adapt this. I found out how to change the textcolor after a custom command for the rest of the document by including this at the beginning of my Markdown document:
\newcommand{\x}{\color{red}}
Like this, the text color switches to red after I write \x somewhere in the text. The next step would be along these lines:
\newcommand{\x}{%
\ifthenelse{\equal{\color}{black}}% if the text color is currently black
{\color{red}}% set it to red
{\color{black}% else set it back to black}}
I want this custom command to check the current text color. Like this, I could ideally have some unchanged text and \x wrap the changed section in the custom command, making this red \x, before going back to the original color.
Does anyone have an idea how I could write this in Latex? Any help appreciated!
Using a similar approach as in https://stackoverflow.com/a/52390056 , you could change the behaviour of **...** to give red text instead of bold:
\renewcommand\textbf[1]{\textcolor{red}{#1}}
i am trying to accomplish the following behavior with a QML TextArea:
I want single Words in the Text to be colored differently
I want the "select"-functions to be working for automated scrolling (user interaction is disabled)
There is a stream of text in the TextArea where one Word needs to be selected(highlighted). The user is requested to input some text elsewhere and press enter to proceed (not part of the question). After that the selection jumps to the next word and the last selected word is either colored green or red. There is only a small portion of the text visible (a few lines, managed by the TextArea height – not part of the question) and i need the text to scroll if the next word is out of that visible range .. therefore the selection is quite helpful because all interaction from the user – to scroll or select or whatever – is disabled (disabling is not part of the question)
my main problem is: if i use textFormat: TextEdit.RichText i can easily color the text how i like it to be (<font color=\"green\">{}</font>) but i cannot use the "select"-functions anymore because – as i would guess – the selection works on the "plaintext" and cannot correspond to the "richtext"-selection? Anyway selectWord() etc. does not work QTextCursor::setPosition: Position '-1' out of range is the result. But if i disable the RichText i don't know how to color the text. Maybe i could live without the selection if i could detect the current word – which would be colored blue etc. – and scroll if its out of the visible area to "fake" the selection behavior, but that's just a third option.
I would really either know how to color non-Rich Text or how to select Rich Text in a TextArea.
You can use QSyntaxHighlighter to highlight the words independent of the selection. See QQuickTextDocument and How to implement rich text logic on QML TextEdit with QSyntaxHighlighter class in Qt for more details.
I want to paste the text with the same height,width,color etc (i.e same as the time of copying the text).
I am using a textArea where i am adding text and also changing the color,font,size of the text by using style but if i am coping the text from textArea and pasting them then i am getting the text with default font style (Only changing heights are coming).
I have attached the image where you can see the difference
So anybody have an idea how to solve this problem ?
Maybe you can use a TextFlow and TextConverter with the methods export and importToFlow to use and TextConverter.TEXT_FIELD_HTML_FORMAT to get the format with the style attributes
I have one text box with multiple line option. Now i want type the words inside the text box with different font-size and different colors. Is it possible?
it's not possble.. you can use a WYSWYG editor, like http://nicedit.com/
In my application, I am using a BarChart to display data. However, the text in the category axis can be too long to display on the chart, so flex adjusts the font size automatically to the point that the data is either unreadable, or the text is partially visible.
The length of the text varies every time new data comes in, so I can't set the gutterLeft attribute to a static value at runtime.
Two things that come to my mind are:
Change the gutter dynamically according to new data
Have a scroll bar on the categoryaxis so that if any text won't fit in the space, the user can scroll to see it
Any help would be appreciated.
EDIT:
I have hundreds of rows of data being graphed at once, so I can't really use a legend for each item.
Also, I have no idea how to change the gutterLeft property with actionscript. Doing it in MXML is as simple as
gutterLeft="100"
but I cannot access the property using actionscript. I also tried to bind the gutterLeft variable to an integer and change that integer and it still didn't work. :|
the problem is that gutterleft is a style, and therefor needs to be set as one when using actionscript.
I was hoping to see your code to give a more detailed answer but what you want to do is:
mychart.setStyle("gutterLeft",500);