calculating the hscroll value in a custom scrollbar

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Sjatplat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 75
Joined: Wed Jun 22, 2011 1:53 pm

calculating the hscroll value in a custom scrollbar

Post by Sjatplat » Tue Mar 25, 2014 6:27 pm

I'm making a simple custom scrollbar and I'm trying to calculate the scroll value so it relates to the groupscoll value of the target.

Does anybody know the formulae for this?

The scollbar consist only of two graphics - the border of the scrollbar and the thumb.

Sjat
Last edited by Sjatplat on Tue Mar 25, 2014 9:10 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: calculating the scroll value in a custom scrollbar

Post by dunbarx » Tue Mar 25, 2014 7:19 pm

Hi.

Is the "thumbPosition" property what you are looking for? I am not sure what you intend to relate this value to. Is there a correspondence to the scroll property of a group? If so, you can scale the thumbPosition and the scroll of the group together.

Craig Newman

Sjatplat
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 75
Joined: Wed Jun 22, 2011 1:53 pm

Re: calculating the scroll value in a custom scrollbar

Post by Sjatplat » Tue Mar 25, 2014 7:52 pm

Thank you for answering.
I think i got the formulae of resizing my custom thumb according to the group: formattedwidth-width of the target group and then calculate the percentage of this relation to get my custom thumb the right size.

let's say I then put my custom thumb at the very end (in the right end of my scrollbargroup) and want to calculate the hscroll value of this position (so its the same as the hscroll end of the target).
Is it the endposition(the right of the thumb)- the width of the thumb/2???

As you see - i have a hard time even explaining... :D

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: calculating the hscroll value in a custom scrollbar

Post by dunbarx » Wed Mar 26, 2014 4:27 am

Hi.

It is not the width of the thumb (which has its own property, the "thumbSize") but rather the start and end value of the scrollbar itself. Make a new scrollbar. In the inspector you will see properties that are settable, especially the start and end values. These can be scaled in many ways. So if you had a total spread of 100, say, then when that thumb was halfway along, you could then set another scrolling object, like your group, similarly.

Or anything else. Maybe the other scroll percentage could be different, so that when the scrollbar was 50%, the group scroll was only 25%. Do experiment with various different scrolling objects, and set their start and end values in playful ways.

Is this what you needed?

Craig

Post Reply