scale w/ ticks and snap-to

Richard Gaskin ambassador at fourthworld.com
Tue Mar 1 21:47:14 EST 2005


Éric Chatonet wrote:
> I proposed a little script to manage a scrollbar with snap-to behavior 
> so the indicator lines up with the ticks (displayed with Mac OS).
> In fact, my script (changing the numberFormat property) was too much 
> complicated.
> The following code is enough to do the job:
> 
> on scrollbarDrag pPos
>   set the pageInc of me to the endValue of me / (the endValue of me + 1)
> end scrollbarDrag
> --------------------------------
> on mouseUp
>   set the thumbPos of me to round(the thumbPos of me)
> end mouseUp

The behavior seems to work the same here for me with a script containing 
only:

on mouseUp
   set the thumbPos of me to the thumbpos of me
end mouseUp

Since the thumbpos is an integer, it does the post-drag snap-to.  I had 
hoped to find a snap-as-you-go behavior, and I've gotten close but it's 
still a tad jerky (if only we had a preScrollBarDrag message <g>).

But here's where things get freaky - try this at home:

1. Make a new mainstack
2. Drop a scale onto it
3. Set these properties:
      startValue: 1
      endValue:   5
      pageInc:    1
      lineInc:    0
      thumbsize:  1

Freak-o-rama:  I see a slider with 4 (count 'em, four!) tick marks. 
With a scale of 1 to 5, I would expect 5.

Ultra-freak-o-rama:  Éric's has the same properties set just like mine, 
but his has 5 (count 'em, five!) tick marks.

Works the same in Rev and MC.

The mystery deepens: I can copy Éric's, change the endValue to 6, and 
get 6 tick marks.  But if I change the endValue to 4 I get 3 tick marks.

How comes such to be?  :\

You can examine both scrollbars here:

   go url "http://fourthworld.net/scroll_bar_test.mc"

Paul Looney, Ken Ray, and I have scratched our heads over this today.

Mystified?

Scroll down for spoiler:





















It turns out that while Eric's first handler doesn't affect behavior, it 
does affect appearance.  This bit:

  on scrollbarDrag pPos
   set the pageInc of me to the endValue of me/(the endValue of me +1)
  end scrollbarDrag

...apparently takes care of a bug in the engine.  As soon as you scroll 
it you get the tick marks appearing as you would expect.  Apparently 
this continues to work even with that handler disabled until the next 
time the pageInc or thumbSize is set.

I could't find a Bugzilla report for this, so I just filed one:
<http://support.runrev.com/bugdatabase/show_bug.cgi?id=2644>

Freaky, but at least there's a workaround.

Thanks, Éric.

-- 
  Richard Gaskin
  Fourth World Media Corporation
  ___________________________________________________________
  Ambassador at FourthWorld.com       http://www.FourthWorld.com


More information about the use-livecode mailing list