scale w/ ticks and snap-to

J. Landman Gay jacque at hyperactivesw.com
Sat Feb 26 23:59:45 EST 2005


On 2/26/05 5:15 PM, Richard Gaskin wrote:

> I'd like to have a scale in a range from 1 to 5 with 5 ticks on it, and 
> with snap-to behavior so this indicator will line up with the ticks.
> 
> Any combination of properties for this, or am I rolling my own?
> 

You have to write your own. There's one in the "Colors and Levels" menu 
item in my Blocks game. This is the script of the scrollbar (there are 
only 3 positions):

on mouseUp
   setLevelValues
end mouseUp

on setLevelValues
   put the endvalue of me div 3 into theSegment
   put the thumbpos of me into thePos
   switch
   case (thePos < theSegment)
     set the thumbPos of me to 0
     break
   case  (thePos < theSegment*2 + 10)
     set the thumbPos of me to the endvalue of me div 2
     break
   default
     set the thumbPos of me to the endvalue of me
   end switch
end setLevelValues

I forget why I added 10 in the second case, but it had something to do 
with esthetics.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com


More information about the Use-livecode mailing list