Hi all,
the default switch button control is great - if you want a binary choice.
As part of a project I needed a tri-state control (not just left/right, but left/centre/right) so rolled my own...
Sharing it both because others may find it useful but also because resizing is still a bit iffy (I try to maintain aspect ratio, which works but it's a bit... twitchy), so hoping others may have a better way of doing it and grateful for advice... usage should be self explanatory...
S.
Tri-state switch control
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Tri-state switch control
- Attachments
-
- sk3Switch.livecode.zip
- (3.67 KiB) Downloaded 80 times
-
- VIP Livecode Opensource Backer
- Posts: 4027
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Tri-state switch control
Stam,
That is a nice control. Thank you.
Re: twitchy:
at margins of 4 (your current setting)
try in resizeControl handler
Don't ask me why, it has to do with the margins and all. Do not have the time to really understand this right now.
But is less "twitchy"
Kind regards
Bernd
That is a nice control. Thank you.
Re: twitchy:
at margins of 4 (your current setting)
try in resizeControl handler
Code: Select all
put tNewRect into tRect
add 4 to item 1 of tRect -- change
add 6 to item 2 of tRect -- change
But is less "twitchy"
Kind regards
Bernd
Re: Tri-state switch control
Bernd, as always thank you.
I don't understand why either but it works
Currently this is set as a 2:1 width/height ratio but will add a custom prop that can modify this to produce more elongated controls (ratio of 2.5 or 3 seems good for this) and will post on Sample Stacks/LiveCodeShare.
And when I get time, sparse as it is, I'll look into making this into one of the new script widgets, seems like a good candidate for this...
Thanks once again,
Stam
I don't understand why either but it works
Currently this is set as a 2:1 width/height ratio but will add a custom prop that can modify this to produce more elongated controls (ratio of 2.5 or 3 seems good for this) and will post on Sample Stacks/LiveCodeShare.
And when I get time, sparse as it is, I'll look into making this into one of the new script widgets, seems like a good candidate for this...
Thanks once again,
Stam
Re: Tri-state switch control
Hi Bernd, just a quick note to say that building this as a script widget was both quick and fun - and no longer any need to control aspect ratio (and no twitch ) - aspect ratio changes as it should do with resizing and it's much smoother now.
And more importantly both the value of the switch and the colours can be set in the IDE's property inspector (this does require LC10 DP5 or higher to work though...)
I've shared the source code and a compiled extension under MIT licence here: https://github.com/stam66/tristate
Best regards
Stam