Determining control background color

How can I programmatically determine the background color of a DesktopListbox or TextField?

I’m aware I can set them, but I’d like to be able to use the OS color that is set so I can make other custom elements match.


TextFields (and Buttons, and other controls) are transparent in Dark Mode on macOS, so the color isn’t really a color. Listbox being an entirely custom Xojo control isn’t transparent though, and you can match to named colors.

Sam’s app Aqua Swatch can help you figure out what named colors go where on macOS, but with things being transparent it will be a struggle to make a fake control match a real one.

You can use Declares or Plugins to get the named colors into the DrawingColor, or you can use a ColorGroup if you don’t really mind that still to this day they cannot be namespaced into a Module.

Windows has its own system of named colors, but I don’t know of a tool like Sam’s that helps for Windows. I usually find myself just setting hand-selected values for Windows.