little confused with the thumbPos of a slider

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

LittleGreyMan
Posts: 49
Joined: Sat Jun 16, 2012 7:57 pm

Re: little confused with the thumbPos of a slider

Post by LittleGreyMan » Tue Aug 14, 2012 9:55 pm

dunbarx wrote:As for getting the numberformat property, placing a "0" in the inspector will revert to empty when you reload it. I guess "0" and empty are the same.
I think you're right, Craig. I had doubt that the actual value was not an integer, as I had some unexpected issues, but the bug was not in the IDE :D
Best regards,

Didier

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

Re: little confused with the thumbPos of a slider

Post by bn » Tue Aug 14, 2012 11:06 pm

Hi,
to add a little to the thumbPos story. Make a new slider set its endvalue to 3 as Craig did. Set the script of the slider to

Code: Select all

--on scrollbardrag theValue
--   put theValue + 0 & return & the thumbposition of me + 0 into field 1
--end scrollbardrag

on scrollbardrag theValue
   put theValue & return & the thumbposition of me into field 1
end scrollbardrag
drag the slider. Now just comment the second scrollbarDrag handler out and uncomment the first scrollbarDrag handler.

Acutally the thumbposition could not be an integer because LiveCode has to divide the width of the slider by the difference between start- and endValue of the slider. This would rarely be an integer. In contrast the parameter passed to the scrollbarDrag handler (theValue) is an integer and can be used as such.
For me the lesson is: in a scrollbarDrag handler I use the accompanying parameter for integer and if I have to access the thumbposition from a different script always treat it as an decimal and format it as needed. Only set the numberformat of the slider if I want to display fractions of the values on the slider.
Kind regards
Bernd

MouseUp
Posts: 41
Joined: Sun Feb 14, 2010 3:41 pm

Bug or Feature with the thumbPos of a slider???

Post by MouseUp » Thu Apr 18, 2013 7:51 pm

Perhaps this will summarize and help clarify this feature or BUG...

For some unknown reason, when we try any kind of math with the thumb position,
the slider starts sending very fine values with decimals added on! Round gets rid of this...

Code: Select all

on mouseStillDown
     put the thumbPosition of me -- puts only whole numbers
end mouseStillDown

Code: Select all

on mouseStillDown
   put (the thumbPosition of me)+0 -- puts whole number & 6 decimal digits
end mouseStillDown

Code: Select all

on mouseStillDown
   put round(the thumbPosition of me)+0 -- puts only whole numbers
end mouseStillDown
Thanks,

MouseUp

Post Reply