-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toggle Button created using Slider #4310
Conversation
Hi @rustbasic What you are proposing here is not a toggle button but a switch. Semantically speaking, egui already has support for toggle buttons. From an accessibility point of view, this new widget would be very confusing as is because:
I'll let @emilk decide whether using the slider as a building block for a switch is a good idea or not, but there is more in a switch than just being able to slide something from left to right. A switch is semantically closer to a check box. |
Thank you for review. It seems like it was written without use. For example, |
There is already a toggle switch implementation in the demo app. It is provided as an example of how users can write their own widgets. If egui were to have a toggle switch widget, it would probably be implemented like this. But currently anyone who needs it can just copy those 20 lines of code, and then customize it if they want. |
Yes, this is just to provide it in an easier and simpler way. |
As DataTrinity pointed out, this is a bad way of implementing a toggle switch. At some point I'd like to have a global option to show checkboxes as toggle switches, i.e. like a styling option. But this PR is not it. |
Okay. I thought it would be better to have something simple to implement rather than nothing. |
rounding
into account when usingSlider::trailing_fill
#4308Toggle Button created using Slider.