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 IDEdunbarx 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.
little confused with the thumbPos of a slider
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
Best regards,
Didier
Didier
Re: little confused with the thumbPos of a slider
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
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
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 scrollbardragAcutally 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
Bug or Feature with the thumbPos of a slider???
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...
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
MouseUp
