Set different text colors to ComboBox items

Started by Maksat, 10 March 2019, 11:41:25

Maksat

Hi everyone!
Is it possible to set a different color to specific items? I want to add item with grey color, which will mean that the item is not available.

Or how can I hide selected item from items list? Or is there any function like tgui::EditBox::setDefaultText? sorry for my bad English=)

texus

QuoteIs it possible to set a different color to specific items?
This is currently not possible.

QuoteI want to add item with grey color, which will mean that the item is not available.
Would you still want the user to be able to select the item? If not then it would be better not to include the item.

Quotehow can I hide selected item from items list?
In order to hide items from a list, just clear the list and fill it again with the items you want to show.

Quoteis there any function like tgui::EditBox::setDefaultText?
What should the function do exactly? Place some text in the ComboBox when none of its items are selected yet?

Maksat

I'm making music game which uses MIDI ports. If users were using some port(port 1) and it becomes unavailable, I want to let them know, which port they were using last time
this example I made in Photoshop
https://www.dropbox.com/s/f4fpmsm2lmn1gfm/ComboBox.png?dl=0

Maksat

Quote from: texus on 10 March 2019, 11:54:38
What should the function do exactly? Place some text in the ComboBox when none of its items are selected yet?
Yes

texus

#4
The top example in your image would be harder to implement as it requires being able to set a different color for each item.
The bottom example can be implemented by just adding a default text. When the port becomes unavailable you just have to deselect the item, remove it from the list and set the default text.

So if it is enough for you then I'll just add a DefaultText property to ComboBox and a DefaultTextColor property to ComboBoxRenderer.

Edit: the default text was added to ComboBox (in the version that can be downloaded on github)