Xojo2018r3: Alternating colors in Listbox for darkmode

Hi!

I use a custom Listbox Sub class im many of my apps where an alternating background color is used. I get these colours via some declares:

Declare Function controlAlternatingRowBackgroundColors Lib "AppKit" selector "controlAlternatingRowBackgroundColors"(ob_id As Ptr) As Ptr

I use it with Xojo´s “TextColor” and I get following colors:

TextColor = &c00000026 alterntingBackgroudColor (1) = &cF1F2F200 alterntingBackgroudColor (2) = &cFFFEFE00

It works also in Darkmode, where I get

TextColor = &cFFFEFE26 alterntingBackgroudColor (1) = &c16161600 alterntingBackgroudColor (2) = &cFFFEFE00

The problem is that the text is not visible on “alterntingBackgroudColor (2)” since both are nearly white.

Do I miss something or do I need to adjust this manually?

Your color conversion does not calculate the alpha value correctly. AlternatingBackgroundColor(1) (when I start with an index of 0) is &cFFFFFFF3 in Dark Mode.

Also there has been a discussion on the prerelease channel about matching the looks of native Tableviews. @Thom McGrath found out that a ClearRect in CellBackgroundPaint helps to get similar results.

Somethings not right there. You shouldn’t be getting something close to white for the second background color in dark mode. Have you tried requesting indexes 0 & 1 instead of 1 & 2?

I also suggest just using TextColor for the text. That will give you the correct system color.

Almost white is quite ok, but almost fully transparent too (2nd row, 2nd & third to the right):

I did in fact ignore the Alpha component of the color which was fine in light mode. Now with Alpha channel the color looks fine and the alternating colors are Ok.

Thanks for your help.