Is there a way to have a different text appear in the ComboBox’s drop-down than what is in the drop-down list itself? We’d like to abbreviate one of the entries in one of our ComboBoxes, but I can’t see any way to modify the text that gets drawn in the button itself. Is there a Look&Feel method for that?
NOTE: we do NOT want to CHANGE the text for the selected item; we just want the drawing of the text to use an abbreviated version of the text in the drop-down list, due to space issues. But I can’t find if there is a Look&Feel for drawing the text of the ComboBox’s button.
If you mean drawing the text of a comboBox’s Label, that method is:
LookAndFeel::drawLabel(Graphics& g, Label& label)
This does all labels and the displayed text in ComboBoxes (which is a Label).
You could possibly do something like dynamic cast the parent to a ComboBox, search for specific text String, and then modify it before drawing it.
auto text = label.getText();
if (dynamic_cast<ComboBox*>(label.getParentComponent()))
{
if (text == "MyCertainString")
text = "newString"
}
// draw the text
