Page 1 of 1

Hilite List Question

Posted: Fri Jun 15, 2012 10:28 pm
by townsend
I've got a Text Field that is set for Mutiple Hilites but as soon as I change cards any lines selected or hilited disappear.
So this code saves all the hilited lines to a global variable:

Code: Select all

on closecard
     global saved
     put hilitedline of fld "main.list" into saved
end closecard
Fine. Now I want to restore those selected lines when the card reopens.
You can't select multiple lines the way you would ordinarily select individual lines.

Code: Select all

on opencard
     select the line of fld "main.list" to saved
end opencard
So I tried to iterate through the list of saved lines to restore them one by one.

Code: Select all

on opencard
     put number of items in saved into cnt
     repeat with ii = 1 to cnt
          put item ii of saved into here
          select line here of fld "main.list"
     end repeat
end opencard
The loop works fine, except each subsequent select clears all previously selected lines,
even though the text field remains set as Multi Hilite.

I tried experimenting with the SelectedLines function, but that didn't work.
Nothing much in the Dictionary on this, and I searched the forum too.
Any suggestions would be appreciated.

Re: Hilite List Question

Posted: Sat Jun 16, 2012 4:49 am
by dunbarx
Hi.

I love custom properties:

Code: Select all

on closeCard
   set the hiliteHistory of fld "yourField" to the hilitedLines of fld "yourField"
end closeCard

on opencard
      set the hilitedLines of fld "yourField" to the hiliteHistory of fld  "yourField"
end opencard
The moral of the story is to read up on the hilitedLines property.

Craig Newman

Re: Hilite List Question

Posted: Sat Jun 16, 2012 11:54 am
by Klaus
Hi all,

globals or custom properties 8) , you can GET and SET the hilitedlines of a (list) field!
So this works:
...
global gSaved
set the hilitedlines of fld "main.list" to gSaved
...

Best

Klaus

Re: Hilite List Question

Posted: Sat Jun 16, 2012 3:52 pm
by townsend
Thanks Craig-- Thanks Klaus--

One of the best things about LiveCode is this community forum!