iTunes-type alternate colored lines in scrolling list field

Jan Schenkel janschenkel at yahoo.com
Tue Feb 25 11:54:00 EST 2003


<argh> accidentally hit the 'Send' button before I was
finished editing this post </arg>

--- "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,

There are two ways to go, depending on what you want.
1) if you're okay with 'line-per-line' scrolling of
your field, you can simply:
- create a pattern in your favourite painting app
- import it as an image
- use the 'Colors' palette to set the
backgroundPattern of the field to your imported
pattern
- 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) if you want pixel-per-pixel' scrolling, things get
a bit more complicated, but it is possible ; 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
Now 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