slider unexpected behavior

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
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

slider unexpected behavior

Post by jmburnod » Thu Sep 09, 2010 10:36 am

Hi,

I have two scrollbar identical, scrB1, scrB2

Orientation : horizontal
Style : scale
Width = 100
Height = 42
Starvalue = 1
EndValue = 100
ShowValue : true
PageInc = 10

They have an unexpected behavior, i can't get some value with the slider

scrB1 jump 3
scrB2 jump 10


Best

Jean-Marc
Attachments
SliderJumpValue.rev.zip
(1 KiB) Downloaded 208 times
https://alternatic.ch

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: slider unexpected behavior

Post by Klaus » Thu Sep 09, 2010 11:56 am

Hi Jean-Marc,

sorry, I don't get it, what exactly is the problem?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: slider unexpected behavior

Post by bn » Thu Sep 09, 2010 12:09 pm

Hi Jean-Marc,
I think this is due to the fact that Rev internally does a floating point operation and you have a rounding error because the width of the scrollbar is the same as the endvalue. To see this effect you can put

Code: Select all

on scrollbarDrag
   set the numberformat to ".###"
   put the thumbposition of me + 0
end scrollbarDrag
into the scrollbar.
To change this behavior you will have to set the width to something bigger then 100. A width of 130 gets rid of this in my trials. Setting the thumbposition by script works for width of 100.

regards
Bernd

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: slider unexpected behavior

Post by bn » Thu Sep 09, 2010 1:39 pm

Jean-Marc,

if you look at the slider closely it turns out that at a width of 100 the actual width of the marks is smaller. As soon as you set the width of scrollbar to a width that equals 100 pixel for the marks then you get the correct behavior.
So the width of the scrollbar in the inspector is not the width of the "scrolling" line. No wonder there are "rounding errors".

regards
Bernd

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: slider unexpected behavior

Post by jmburnod » Thu Sep 09, 2010 4:00 pm

Klaus,

Bernd explane the trouble in his post

With a width 152 the slider work fine

Best

Jean-marc
https://alternatic.ch

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: slider unexpected behavior

Post by Klaus » Thu Sep 09, 2010 5:21 pm

Hi friends,

yep, got it now :D

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: slider unexpected behavior

Post by jmburnod » Thu Sep 09, 2010 9:45 pm

Yes Klaus,

With the german staff i can go far

All the best

Jean-Marc
https://alternatic.ch

Post Reply