Vaadin 23 change text color for TextField component - vaadin

In case of error, I need to change the text of TextField to var(--lumo-error-text-color)
I tried the following:
textField.getStyle().set("color", "var(--lumo-error-text-color)");
but it doesn't work. How to properly change the text color of TextField component?

That does work just fine for me. However, assuming you want all TextFields to have red text when they're invalid, that really would be more appropriate to handle in CSS: Just add the following block to your styles.css:
vaadin-text-field[invalid]::part(input-field) {
color: var(--lumo-error-text-color);
}
Or, if you want that across all text input fields, skip the element name:
[invalid]::part(input-field) {
color: var(--lumo-error-text-color);
}

Since the text field is slotted, I don't believe you can set it's color property inline. You can add/remove a class name and use the method suggested above. Just have one class set the text to error color and the other class set it back to the regular color.

Related

Is it possible to change the color of a MaterialDesignIcon?

I use a MaterialDesignIcon in a label like this:
Label info = new Label("Label", MaterialDesignIcon.AC_UNIT.graphic("-fx-fill: red;"));
I don't know what CSS is supports (https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html) but I thought it was Text. -fx-underline worked and so did -fx-font-size. I understand that other font properties don't always work because the font doesn't support them, so that's fine. None of the Shape properties worked so the above fill doesn't do anything.
I only see the colors change by the Swatch but I want something local. What CSS properties are supported and how can I change a single icon's color?
MaterialDesignIcon.graphic() creates an instance of Label. So to change its color you can use fx-text-fill: red.
To inspect your GUI you can use ScenicView

how to set setNextFocusDown in TextArea

I am try to use setNextFocusDown method in TextArea eg:
textArea.setNextFocusDown(nextTextField);
But in keyboard it does not show next button so how to set setNextFocusDown in TextArea ?
This will only apply if you do it in the beginning and only for TextArea subclasses. Notice this hint will not apply for every case.

Text selected without showing the pins

Is there a way to programmatically select a text without showing the pins at the beginning and at the end of the selected text?
Example:
Although you should be more precise, I presume you just want to highlight some parts of the text with a background color. Therefore you can use NSAttributedString.
You can look up how to create an attributed String here and how to use background color on it here.

Active Admin Normal Text Field

I'm trying to bring a custom view to an active admins page.
But thing is whenever I try to put a text area field it automatically produces a custom text area field where I can set font and all, something like word editor as shown in picture.
Is there a way I can prevent this and get normal text editor?
Yes. TinyMCE lets you specify a html class that prevents it from activating. Text fields with that class will not get transformed into the editor.
http://www.tinymce.com/wiki.php/Configuration3x:editor_deselector
Where you initialize TinyMCE, add these options:
tinyMCE.init({
//your init code
editor_deselector: 'selector', //replace this with the HTML class of your choice
//more of your init code
});
Any text area that has the specified class will not get transformed into an editor.

GridPanel cell editing of type 'textfield'

I'm using a GridPanel with the 'CellEditing' plugin.
My editor cell is of type 'textfield'.
I have 2 questions:
I would like to change the background color of empty cells so that it would be easier to see where there are missing values.
When double clicking a cell, I would like to format the text of the textfield. How do I get to the textfield object?
Thank you,
Dana
You might give the textfield an id property.
field: {
id: 'myId',
...
}
Access the field with
var objTextfield = Ext.getCmp('myId');
About the color, you must add or overwrite the CSS. You can set a config property 'cls' to a custom css class. See here: http://docs.sencha.com/ext-js/4-0/#/api/Ext.form.field.Text-cfg-cls

Resources