iTunes-type alternate colored lines in scrolling list field
Jan Schenkel
janschenkel at yahoo.com
Wed Mar 5 06:43:01 EST 2003
--- Greg Saylor <gsaylor at net-virtual.com> wrote:
> Hello,
>
> I was very interested in this, because it's exactly
> what I want to do...
> But, I am wondering how can you do this so that it
> is even more like
> iTunes?... What I mean is, I need to be able to
> sort the various columns
> with the little vertical arrows depending on which
> field was sorted and
> how it was sorted... The fields I have are going to
> be either numeric,
> alphanumeric, and a date in the format of
> "03-02-2003"...
>
> Thanks so much!
>
> - Greg
>
Hi Greg,
While I can't give you a complete stack to play around
with at the moment, I'll give you a few hints:
- set the script of the field to something like this:
setProp uSortColumn pColumnAndDirection
-- pColumnAndDirection form ::
<number>,<direction>
put item 1 of pColumnAndDirection into tColumn
put item 2 of pColumnAndDirection into tDirection
set the itemDelimiter to tab
sort lines of me tDirection by item tColumn of
each
-- pass so you can retrieve this info later
pass uSortColumn
end uSortColumn
- create rectangular buttons above the field
- set their labels, change the alignment to left so
you can have icons on the right side of the buttons
- set their scripts to something like this:
constant kAscendingIconID = "123456"
constant kDescendingIconID = "654321"
-- better find suitable icon IDs for this
on mouseUp
-- this assumes it's the second column
switch the icon of me
case kDescendingIconID -- a triangle pointing down
-- sorted descending, so we must sort ascending
set the uSortColumn of fld "TheList" to \
"2,ascending"
set the icon of me to kAscendingIconID
break
case kAscendingIconID -- a triangle pointing up
-- sorted ascending, so we must sort descending
set the uSortColumn of fld "TheList" to \
"2,descending"
set the icon of me to kDescendingIconID
break
default -- no icon set for this button
-- hasn't been sorted on this column yet
-- so we'll set it to our preferred initial sort
set the uSortColumn of fld "TheList" to \
"2,ascending"
set the icon of me to kAscendingIconID
break
end switch
end mouseUp
- you can add things for numeric sorts, and the like
- have a look at the stack Chipp Walters made for
resizing columns ; it's available at :
http://www.altuit.com/webs/altuit2/RunRev/Downloads.htm
- however, things can get complicated if you want
different alignments per column ; in such cases, you
might want to overlay those columns with opaque fields
with the correct alignment, and adapt the script of
the field :
setProp uSortColumn pColumnAndDirection
-- pColumnAndDirection form ::
<number>,<direction>
put item 1 of pColumnAndDirection into tColumn
put item 2 of pColumnAndDirection into tDirection
set the itemDelimiter to tab
sort lines of me tDirection by item tColumn of
each
-- update the fields with different alignment
-- this assumes column 3 is right-aligned instead
repeat for each line tLine in me
put item 3 of tLine & return after tColumn3
end repeat
-- update, char 1 to -2 to avoid the trailing
return
put char 1 to -2 of tColumn3 into fld "Column 3"
-- pass so you can retrieve this info later
pass uSortColumn
end uSortColumn
on selectionChanged
-- update the fields with different alignment
set the hilitedLines of fld "Column 3" to \
the hilitedLines of me
-- don't forget to add a similar
'selectionChanged'
-- handler to those fields !
end selectionChanged
Making a nice sample stack for these purposes is on my
ever-growing "to do"-list, but I hope these hints got
you started.
Best regards,
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