I am trying to inject CSS styles into a SelectItem.
Here is my desired results:
I have been following the example in the Showcase entitled “Styled ComboBox”
Here is my sample program:
Additionally, I am using this .css file:
This comes close to achieving what I would like.
Here of the deficits that I haven’t been able to find a solution for:
I have attached a screenshot that shows where a row has blue background for the test and white background for non-text.
Here is my desired results:
- The pick list has three styles: a) regular row, b) alternate row, c) row with cursor over it.
- Once an item is picked the style in the text box area is the same as regular row above.
I have been following the example in the Showcase entitled “Styled ComboBox”
Here is my sample program:
Code:
[B]public[/B] [B]class[/B] ComboBoxStyleEntry [B]implements[/B] EntryPoint {
@Override
[B]public[/B] [B]void[/B] onModuleLoad() {
form().draw();
}
[B]private[/B] DynamicForm form() {
[B]return[/B] [B]new[/B] DynamicForm() {
{
setBorder("1px solid black");
setAutoWidth();
setAutoHeight();
setItems(comboBox());
}
};
}
[B]private[/B] SelectItem comboBox() {
[B]return[/B] [B]new[/B] SelectItem() {
{
setValueMap(IntStream.[I]rangeClosed[/I](1, 5)
.mapToObj(n -> "Row " + n)
.collect(Collectors.[I]toMap[/I](x -> x, x -> styledItem(x), (x, y) -> x, LinkedHashMap::[B]new[/B])));
setTextBoxStyle("ComboBox");
setPickListBaseStyle("ComboBox");
setShowTitle([B]false[/B]);
}
[B]private[/B] String styledItem(String itemName) {
[B]return[/B] [B]new[/B] StringBuffer().append("<span style='")
.append("color: rgb(255, 255, 255);")
.append("font-family: \"Open Sans\", arial, helvetica, sans-serif;")
.append("font-size: 120%;")
.append("font-weight: 600;")
.append("background: rgb(0, 144, 217);")
.append("'>")
.append(itemName)
.append("</span>")
.toString();
}
};
}
}
Additionally, I am using this .css file:
Code:
[I].ComboBox[/I][B],[/B]
[I].ComboBoxDark[/I][B],[/B]
[I].ComboBoxFocused[/I][B],[/B]
[I].ComboBoxFocusedDark[/I][B],[/B]
[I].ComboBoxOver[/I][B],[/B]
[I].ComboBoxOverDark[/I][B],[/B]
[I].ComboBoxSelected[/I][B],[/B]
[I].ComboBoxSelectedDark[/I][B],[/B]
[I].ComboBoxSelectedOverDark[/I]
{
background: [I]rgb(0,[/I] [I]144,[/I] [I]217)[/I];
}
Here of the deficits that I haven’t been able to find a solution for:
- When I mouse over the pick list every other row renders with a white background but the text has the blue background.
- On the alternative rows the background remain blue for the entire area.
- I haven’t found a way to complete change the style with a mouse over.
I have attached a screenshot that shows where a row has blue background for the test and white background for non-text.
Comment