deleting lines from a list-field

Sarah Reichelt sarah.reichelt at gmail.com
Mon Jun 23 23:47:07 EDT 2008


On Tue, Jun 24, 2008 at 12:57 PM, Nicolas Cueto <niconiko at gmail.com> wrote:
> I'm hoping there's an elegant
> way of doing the following,
> cause my "solution" is pretty
> messy.
>
> I have a locked field set to
> list-behavior, multiline, and
> non-contiguous. Now, say
> that in that field there are
> 10 lines, of which the user
> has selected lines 1, 3-to-6
> and 8 for deletion.
>
> My first solution so far is to
> put a mouseDouble up
> handler in the field and then
> use the field's hilitedline
> property, something like this:
>
> on mouseDoubleUp
>  put the hilitedline of me into tLinesToDelete
>    repeat for each item tLineNr in tLinesToDelete
>        delete line tLineNr of me
>    end repeat
> end mouseDoubleUp
>
> But, of course, the problem with
> this is that after the first deletion
> the line numbers in hilitedLine
> no longer correspond to the
> actual line numbers in the field.

Count backwards :-)

repeat with x = the number of items in tLinesToDelete down to 1
   put item x of tLinesToDelete into tLineNr
   delete line tLineNr of me
end repeat

Cheers,
Sarah



More information about the use-livecode mailing list