How to change color of selected text in label?

Description

How can I change the color of selected text in a label?

What do you want to achieve?

When text in a label is selected, I want the background to be black and the text color to be white. I’m using the Mono theme, so it shows selections as black text on a cyan background.

What have you tried so far?

I’ve looked at the label’s style options and it only offers the MAIN style. lv_style_t has a sel_color field to let me change the background of selected text, but I see no way to change the selected text’s foreground color.

Thank you,
Bob

There is no way to do it easily in 6.1, from what I can tell. When I implemented text selection I didn’t think of the fact that some displays would need foreground color inversion.

However, it wouldn’t be too complex to add for 7.0. I’ll see what I can do.

I agree. I think it should be only a new property to set the text color too, besides the background color.

1 Like