iTunes-type alternate colored lines in scrolling list field

Malte Brill malte.brill at t-online.de
Mon Mar 17 04:46:01 EST 2003


Hi,

thanks to Yves Coppe for the very interesting off list discussion on this
subject. It helped me getting rid of the last cheesyness of my script. Now
it works quite perfect for me on 1.1.1

Merci Yves!!! :-)

I´ll update my report here.

No changes in the card script:
-----------------------------------------------------------------
global loop,correct,twoLines,skipline

on opencard
  put 1 into loop
  put the effective textHeight of fld "theField"*10 into skipline
  put the effective textHeight of fld "theField"*2 into twoLines
  put skipline into correct
  set the vscroll of fld "theField" to 0
  set the vscroll of grp "theImage" to twolines
end opencard
------------------------------------------------------------------

Change the script of the field to the following:

------------------------------------------------------------------
global loop,correct,skipline,twolines

global loop,correct,skipline,twolines
on scrollbardrag
  if correct-the vscroll of me<=0 then
    repeat until correct-the vscroll of me>=0
      put loop+1 into loop
      put loop*skipline into correct
    end repeat
  end if
  if the vscroll of me+skipline-correct<0 then
    repeat until the vscroll of me+skipline-correct>0
      put loop-1 into loop
      put loop*skipline into correct
    end repeat
  end if
  put the vscroll of me+skipline-correct+twoLines into groupScroll
  set the vscroll of grp "theImage" to groupScroll
end scrollbardrag
-------------------------------------------------------------------


Now it is possible to set the vscroll of the field via script and the scroll
of the group is adapted automaticly.
I would suggest changing the globals to custom properties, if you need more
than one field with alternating lines.

If you want to calculate how many bars your image must have to display
correctly, you need at last as many bars that are needed to fill the height
of your field+12 bars. I would add another 2 bars to the image, just to be
sure. :-)

Regards,

Malte

 




More information about the use-livecode mailing list