Color of radio button text

Is there a way to change the color of the label of a radio button?

I’m building an interface on a dark background and want all my labels to be white. Do I have to make a whole set of separate labels, leave my radio button labels blank and put text labels in there to fake it? Or am I missing something here?

This is typically done using a ContainerControl with a RadioButton whose width is very small (around 20, I think), and a Label to the right. You wire the label up to change the value of the RadioButton on click, and you should be good to go. Just expose the properties you need for the RadioButton on the ContainerControl.

ok… seems like it should work like Text Labels do, if you ask me – since most of a radio button is its text.

I feel like Window should have basic text settings that get inherited by all child objects by default. That would certainly make using non-standard fonts/sizes/colors a heck of a lot easier than it is now (having to change each one separately, or in the case of radio buttons, jump through hoops to make it work).

1 Like

I would open a Feedback Case if this is something you’re interested in seeing added to the language but, if I remember correctly, this was a limitation in how Win32 RadioButtons function (or did a long time ago).

1 Like

On the Mac, you can take advanatge of Apple’s Dark Aqua.

Permissions Reset 2 tells the OS to make the entire application use Dark Aqua.

The Ohanaware App Kit demo application has a “Theme” toggle button which can switch just a window between light and dark. https://ohanaware.com/appkit/OAK2021_demo.zip

There’s also a short demo video of the App Kit The Ohanaware App Kit 2021 Release 2 demo - YouTube

And you can use the code included in the App Kit to tell the OS to even make a single control or group of controls use Dark Aqua.

Finally, there is OS API for setting the label color of system controls, Xojo doesn’t expose it (and may overwrite it) but it is there, see the code for the OWDestructiveButton on how to do it.

The Ohanaware App Kit is included as part of this years Omegabundle, so you can score the source code to make beautiful Mac apps that your customers will love, App Wrapper, ExeWrapper, Anthony’s Graffiti Suite and many others to help you build outstanding applications with Xojo https://www.omegabundle.net/

p.s. I’ve been working really hard on Release 3 of the App Kit and I’m almost ready to show you all the new exciting things that you’ll be able to add to your Mac apps.

VB6 had an option to easily asign a custom color or a system color to a control more than 2 decades ago :thinking:.

3 Likes

Maybe I’m wrong, but I remember Aaron saying that they didn’t provide those abilities due to an API limitation when I asked…

It could’ve been that it could not be implemented well (or at all) on all supported platforms at the time. Either way, it’s something they did not build so we don’t have.

What may not be clear from my post, is that if you adopt Apple’s Dark Aqua, Apple or Xojo will adjust your label color as well.

@Sam_Rowlands Thanks. but the app is on Windows, so I don’t think this is going to help me there.

1 Like

Hi Perry,

One way is the way people tell you, take a radiobutton resize it to 20 x 20 and place a textlabel next to it.
the other way is a custom radiobutton.
Here is my english video:

And here is the German video:

2 Likes

Windows has a Dark Theme now? No?

Thanks to @Sam_Rowlands , I just realized that I have code to do this in my GraffitiColors module for Windows Dark Mode support. What you’re looking for is SetTextColor.

3 Likes

Thanks. That’s pretty cool, but I’m really hoping for something that’s less workaround-y. It seems sort of crazy to me that the text attributes can’t be changed.

It does. I’m not a fan of dark mode. In most cases it looks terrible in my opinion, both Mac and Windows. I’m not just looking to invert the usual background/text relationshop. The background is to be a specific neutral grey, which is the standard for film and video applications. DaVinci Resolve is a good example, which looks this way regardless of the OS dark/light preference:

Or Nucoda/Phoenix, the tool we use for film restoration:

My problem with dark mode is that it always feels so inconsistent and I don’t like using the rest of the operating system in that mode. It’s hard to explain, I just think it’s a really annoying trend and find both operating systems hard to use in that mode. But it doesn’t bother me for specific applications.

That’s perfectly fine, my suggestion was to use the OS Dark Mode, because it is simpler to do and is consistent with other apps (that also support the OS Dark Mode).

Many apps make their own Dark Mode, it takes a lot of effort, in the examples you provide DaVinci Resolve still has a light titlebar (which is easily solved), but it sticks out like a sore thumb.

However rolling your own, also means that you can be more creative and provide a unique interface.

Yeah that’s just on the mac. If you go full screen, which is how most people use it because there’s so much stuff on screen, that goes away.

I just wish I could get into Dark Mode like everyone else, but when it comes to interacting with the OS in general, i find it really jarring. It would be an easy solution…

1 Like

Hi Perry,

Yes it is old that we in xojo can’t change colors of radiobuttons or checkboxes or anything else.
The way that is even less code, all you do is copy and past and change color values is this one:

take a radiobutton and resize it to 20 x 20 set it to transparent.
Then add a text label set this one also to transparent.
Add the mousedown event and any onther you like, for hover and leaving.
in the mousedown event paste this bit of code :
#pragma unused X
#pragma unused Y

RadioButton1.Value=True

Return True

Then the radiobuttno action event:
Past this bit of code:

if me.Value=True then

Label1.TextColor=&c0000ff
Label2.TextColor=&c000000

end if

label2 will be your seconde radiobutton.
If you need only one radiobutton i would use a checkbox.
This is hoe i do it with a checkbox and a label:
Same events:
Checkbox action event:
if me.Value=True then

Label3.TextColor=&c0000ff

else

Label3.TextColor=&c000000

end if
and the label with the checkbox:
#pragma unused X
#pragma unused Y

if CheckBox1.Value=False then

CheckBox1.Value=True

else

CheckBox1.Value=False

end if

Return True

I argree with you, it should be easier to do things like this.

2 Likes

Hi Roger/Richard,

Thank you so much for sharing your radio button. Great work! I tried it and it works perfectly and it is very simple to adapt.

Keep up the great work!

Chris