Recent

Author Topic: [Solved] RadioButton.Color only changes hover color  (Read 3774 times)

nikel

  • Full Member
  • ***
  • Posts: 240
[Solved] RadioButton.Color only changes hover color
« on: January 03, 2025, 02:39:18 pm »
Hello, I have 100 panels and 6 radio buttons in each of them. I want to change color, background color or highlight a single radio button (not the selection). Here's my code:

Code: Pascal  [Select][+][-]
  1. TRadioButton(FPanels[I].Controls[Answers^.UserAnswerNum()]).Color:=clRed;

This only works when mouse hover. How can I set color of a radio button?
« Last Edit: January 04, 2025, 10:00:08 am by nikel »

lainz

  • Hero Member
  • *****
  • Posts: 4690
  • Web, Desktop & Android developer
    • https://lainz.github.io/
Re: RadioButton.Color only changes hover color
« Reply #1 on: January 03, 2025, 02:42:27 pm »
Try using a custom drawn radio button.

For example in bgracontrols there's the svg theme for radio button. You change the theme and you can change the color...

nikel

  • Full Member
  • ***
  • Posts: 240
Re: RadioButton.Color only changes hover color
« Reply #2 on: January 03, 2025, 02:43:58 pm »
Thanks for the quick reply.

nikel

  • Full Member
  • ***
  • Posts: 240
Re: RadioButton.Color only changes hover color
« Reply #3 on: January 04, 2025, 08:36:53 am »
I don't want to use 3rd party solution. Is there any other way to mark radio buttons?

cdbc

  • Hero Member
  • *****
  • Posts: 1951
    • http://www.cdbc.dk
Re: RadioButton.Color only changes hover color
« Reply #4 on: January 04, 2025, 09:40:38 am »
Hi
I have an idea...
The radiobuttons are placed on a panel, right?!?
So my thinking is, why not use the panel's 'canvas' to paint a green line under the selected radiobutton, I mean the radiobutton's 'ON/OFF' is a boolean, so one can run over them in the panel's 'OnPaint' and 'Greenlight' the chosen one.
With a bit of math to figure out the position of the line, it could work nicely =^
Just a thought  8)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

nikel

  • Full Member
  • ***
  • Posts: 240
Re: RadioButton.Color only changes hover color
« Reply #5 on: January 04, 2025, 09:59:49 am »
Thank you sir/madam. That's a good idea.

cdbc

  • Hero Member
  • *****
  • Posts: 1951
    • http://www.cdbc.dk
Re: [Solved] RadioButton.Color only changes hover color
« Reply #6 on: January 04, 2025, 10:25:46 am »
Hi
It's Sir  :D ...no worries...
Have fun
Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

 

TinyPortal © 2005-2018