Deleting lines in a scrolling list box?
Jan Schenkel
janschenkel at yahoo.com
Tue Nov 28 13:08:56 EST 2006
--- Ken Ray <kray at sonsothunder.com> wrote:
> On 11/28/06 4:55 AM, "Scott Kane" <scott at cdroo.com>
> wrote:
>
> > Hi Mark,
> >
> >> No global variables needed and only one button
> with one mouseUp handler:
> >>
> >> on mouseUp
> >> if the hilitedLine of fld 1 is not empty then
> >> delete line (the hilitedLine of fld 1) of fld
> 1
> >> else
> >> beep
> >> end if
> >> end mouseUp
> >>
> >> (Replace "fld 1" with a reference to your field).
> >
> > Absolutely excellent!! Thanks a heap. I knew
> it'd be so simple I'd kick
> > myself *again*. <g> I might actually get the
> hang of it soon. ;-)
>
> Note - make sure the 'multipleHilites' for the field
> is FALSE (meaning the
> user can only select one line in the list), otherwse
> the script above will
> fail. For a more "universal" script, that works with
> both single and
> multiple selections, try this:
>
> on mouseUp
> if the hilitedLines of fld 1 is not empty then
> put the hilitedLines of fld 1 into tHLines
> put the number of items of tHLines into tNum
> repeat with x = tNum down to 1
> delete line (item x of tHLines) of fld 1
> end repeat
> else
> beep
> end if
> end mouseUp
>
> Have fun!
>
> Ken Ray
>
Actually, Ken, the hilitedLines are not necessarily in
the right order - I've used this trick to simulate the
behaviour of drag-selecting lines and putting the
focus on the line that the cursor is over (on Windows
you get a black rectangle around the 'active' line).
So it is slightly safer to:
##
on mouseUp
put the hilitedLines of fld 1 into tLines
if tLines is not empty then
sort the items in tLines numeric descending
repeat for each item tLine in tLines
delete line tLine of fld 1
end repeat
else
beep
end if
end mouseUp
##
Hope this helped,
Jan Schenkel.
Quartam Reports for Revolution
<http://www.quartam.com>
=====
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
More information about the use-livecode
mailing list