Number of slider marks not match with the scale

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
proza
Posts: 14
Joined: Thu Jul 12, 2007 3:34 pm

Number of slider marks not match with the scale

Post by proza » Fri Jul 13, 2007 5:23 pm

I have a slider, range from 0 to 10, but the number of marks that under the slider are one less than the highest value. I tried different max value, but the marks are always one less.

Is this done on purpose?

Thanks!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Jul 13, 2007 6:42 pm

Dear proza,

I don't know why, but Revolution always creates one tick too few and it doesn't allow you to create ticks at distances that are unequal to an integer.

To solve the problem as well as possible, create a slider with startValue 0 and endValue 10, just as you did. Type 0.909 in the message box or in a field and copy the number. Open the property inspector and paste 0.909 in the pageInc field (labeled "On bar click"). You can also set this property by entering the following in the message box:

set the pageInc of scrollbar 1 to 0.909

and hitting enter. Now, when the thumb is on a tick, it will show the right value.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

proza
Posts: 14
Joined: Thu Jul 12, 2007 3:34 pm

Post by proza » Fri Jul 13, 2007 7:23 pm

Thanks Mark.

How do you come up with the number 0.909?
If I change the max value to 20 or 25, will this number still works?
I also notice that at the basic property of the slider, there is something called "value format" (near the bottom part). What is this property for?

Proza

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Fri Jul 13, 2007 11:20 pm

Proza,

The formula I use is simple:

Code: Select all

  (endValue - startValue)
-------------------------------
(endValue - startValue + 1)


= (10 - 0) / 11

but it is not perfect. Sometimes, you will get one tick too many and you will have to adjust the number. Also, the number of pixels between the ticks may be varying, which is ugly.

The theory is that you need one tick extra, but I believe the problem is that Revolution smuggles to get the number below the thumb right. It shows the value for the next tick a fraction too early each time while the thumb is moved from the left to the right, to get the correct value displayed when it arrives at the last tick. So, maybe someone will come up with a better formula.

Mark
[/code]
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

proza
Posts: 14
Joined: Thu Jul 12, 2007 3:34 pm

Post by proza » Sat Jul 14, 2007 4:25 am

I agree that it is not perfect. When I click on the line, the thumb will not arrive at the next tick.

I think the best way is to let the company to fix this bug.

Post Reply