toggle button style

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

toggle button style

Post by NonoNano »

Hello,

I would like to have two toggle buttons that should work in this way:

every time I click on one of the two toggle buttons the other one, if in 'pressed' state, must get in 'non pressed' state (similar to a radio button).
I have easily achieved this behaviour but there is something else I would like to obtain.
I would like that one of the two buttons is always dark (pressed) and the other one is always light (released).
The problem is that when I press a button it gets also 'selected' and its style becomes light even if it is pressed (see "pressed_and_selected.png").
In practice I would like to disable the 'selected' style so I can obtain the described behaviour.
Is it possible? Thanks!
Attachments
pressed_and_selected.png
pressed_and_selected.png (3.47 KiB) Viewed 1296 times
pressed_and_NOT_selected.png
pressed_and_NOT_selected.png (3.51 KiB) Viewed 1296 times
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: toggle button style

Post by ONEEYEMAN »

Hi,
wxWidgets is known to use native OS controls.
If you want that kind of tweaking you probably should consider QT or some other toolkit.

But maybe someone else can help in this area.

Thank you.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: toggle button style

Post by catalin »

NonoNano wrote:I would like to disable the 'selected' style
Is it possible?
Probably, but not without drawbacks.
You can use a focus event handler for that button, and whenever it receives focus you can set it to some other window. But that will also mean that it will never remain focused (aka "selected"), thus it could never be pressed by using spacebar on the keyboard.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: toggle button style

Post by ONEEYEMAN »

catlink,
The OP most likely refer to disable the style visually, not from the execution point of view.

Thank you.
NonoNano
Experienced Solver
Experienced Solver
Posts: 71
Joined: Sun Mar 25, 2018 6:12 pm

Re: toggle button style

Post by NonoNano »

Yeah that's right..but asap I will nonetheless try the solution proposet by Catalin!
Post Reply