B4J Question css stylesheet to change choicebox selected item text color?

GuyBooth

Active Member
Licensed User
Longtime User
I have set up a choicebox and applied colors using a css stylesheet:

B4X:
/* Text in all labels */
.choice-box .label {
     -fx-text-fill: red;
}
.choice-box {
   -fx-backgroundcolor: #ADD8E6;
   -fx-focus-color: midnightblue;
   -fx-faint-focus-color: #ADD8E6;
   -fx-control-inner-background: #ADD8E6;
   -fx-selection-bar: "midnightblue";
-fx-selection-bar-text-fill: "white";
}
The result is:

1608224626422.png


The last line in the stylesheet was supposed to change the text in the selected item (the one with the white checkmark) to white, but it doesn't work.
I have tried applying every combination of properties I can think of but have not hit on the correct one.
None of the suggestions I have seen on stackoverflow have worked.
Can anyone tell me what to use to change text in the selection bar to white?
 

stevel05

Expert
Licensed User
Longtime User
Is that actually a Choicebox with a checkmark or are you using a Combobox? How have you set it up?

I can't find any reference to -fx-selection-bar-text-fill, but for a standard choicebox this works on the focused item.:

B4X:
/* Text in all labels */
.choice-box .label {
     -fx-text-fill: red;
}
.choice-box {
   -fx-backgroundcolor: #ADD8E6;
   -fx-focus-color: midnightblue;
   -fx-faint-focus-color: #ADD8E6;
   -fx-control-inner-background: #ADD8E6;
   -fx-selection-bar: midnightblue;
}
.choice-box .menu-item:focused .label{
    -fx-text-fill: white;
}
 
Last edited:
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User
Is that actually a Choicebox with a checkmark or are you using a Combobox? How have you set it up?
Yes it is a Choicebox. The Checkmark shows up as soon as the .selectedIndex is assigned. To be honest I would prefer it not be there, but it's not a high priority right now.
You solution for the css works perfectly, thank you.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
ahh so it does, I've always used combobox as opposed to choicebox. Possibly for the that reason, but I can't really remember why.
 
Last edited:
Upvote 0
Top