3-way slider control
Paul Dupuis
paul at researchware.com
Wed May 26 11:00:17 EDT 2021
On 5/25/2021 9:08 PM, J. Landman Gay via use-livecode wrote:
>> Regardless, I have decided to use a standard LC slider set to
>> -1,0,+1 with some labels grouped to it. It works like a charm
>> and minimizes the number of graphics/objects and code.
>
> I was interested to see that; it's clever, and it does work if you
> click in the slider bar. But dragging the indicator allows partial
> decimal positions. I don't know if that matters for your purposes.
>
I created a slider with a label on the left and right in a group. The
slider is set to min 0, max 2, inc 1 and it's script is:
on scrollbarDrag pNewPosition
switch pNewPosition
case 0
enable fld "CiC_Label"
disable fld "Src_Label"
set the tooltip of me to "Text style changes will be applied to
CiC only"
set the thumbPosition of me to 0
break
case 1
enable fld "CiC_Label"
enable fld "Src_Label"
set the tooltip of me to "Text style changes will be applied to
both CiC and Source"
set the thumbPosition of me to 1
break
case 2
disable fld "CiC_Label"
enable fld "Src_Label"
set the tooltip of me to "Text style changes will be applied to
Source only"
set the thumbPosition of me to 2
break
end switch
end scrollbarDrag
The set the thumbPosition forces any attempt at sliding to move to only
left, center, and right positions. When left, the left label is enabled,
the right label is disabled, and the tooltip for the slider reflects the
choice. When right, the right label is enabled, left label disabled and
the tooltip updated. When center, both labels are enabled and the tool
tip updated.
More information about the use-livecode
mailing list