iTunes-type alternate colored lines in scrolling list field

Jan Schenkel janschenkel at yahoo.com
Tue Feb 25 11:38:01 EST 2003


--- "valetia at mac.com" <valetia at mac.com> wrote:
> It seems REALbasic allows for that...how do you do
> that in Revolution? :-)
> 
> Valetia
> 

Hi Valetia,

Here's the way I did it :
- create a pattern in your favourite painting app
- import it as an image
- create a rectangle the size of the field > 'Foo'
- set its lineSize to 0
- use the 'Colors' palette to set the
backgroundPattern of the rectangle to your imported
pattern
- group the rectangle > 'Bar'
- set the margins of group "Bar" to 0
- set the lockLocation of group "Bar" to true
- move the group behind the field
- set the field's opaque to false

At this point, you have two choices:
1) either you correct the scrolling so that one line
at a time is scrolled instead of one pixel at a time.
- set the script of the field to :
  on scrollbarDrag
    put the scroll of me into tScroll
    put the effective textHeight of me into
tLineHeight
    if tScroll MOD tLineHeight is not 0 then
      set the scroll of me to \
          ((tScroll DIV tLineHeight) * tLineHeight)
    end if
  end scrollbarDrag

2) or a few more steps are needed to make it scroll
well:
- set the script of the field to :
  on scrollbarDrag
    set the scroll of group "Bar" to the scroll of me
  end scrollbarDrag
  on InitBkgnd
    put the rect of graphic "Foo" into tBgRect
    put the formattedHeight of me into tHeight
    add (tHeight - item 4 of tRect - item 2 of tRect)
\
        to item 4 of tRect
  end InitBkgnd
- and use the message box to :
  set the scroll of grp "Bar" to 1
  set the scroll of fld "List" to 1
  send "InitBkgnd" to fld "List"

You may have to fiddle some positions a bit with
respect to the field margins, and you'll have to make
sure the list field has a fixed line height.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the use-livecode mailing list