macOS style toggle switch

Good afternoon

I’ve seen an old thread here where a macOS style toggle switch was implemented but the links all expired…

Is there a way to create such a toggle switch?
Under SwiftUI it’s a breeze:

Toggle("", isOn: $settings.barcode)
                            .onChange(of: settings.barcode) { value in
                                defaults.set(value, forKey: "Barcode")
                            }
                            .toggleStyle(.switch)

Bildschirmfoto 2022-05-16 um 14.43.40

I mean even Xojo uses it in the IDE though not that beautiful (o;

Bildschirmfoto 2022-05-16 um 14.43.48

thanks in advance
richard

Screenshot of the graphic you want to use,
Set your own colors (if needed)
Create the second state graphics

Add a Canvas,
Resize it to only draw the Switch,
Add MouseDown
Add code;
Use it
You’re done !

there is an entry in the documentation about doing that (or better)…

1 Like

For those of us looking for a control ready to go, Einhugur has one that I use in Lifeboat:

Switch

https://einhugur.com/Html/CustomButton/index.html

1 Like

You can use The ZAZ: ZirconSwitch It’s free.