Hilite List Question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Hilite List Question

Post by townsend » Fri Jun 15, 2012 10:28 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10323
Joined: Wed May 06, 2009 2:28 pm

Re: Hilite List Question

Post by dunbarx » Sat Jun 16, 2012 4:49 am

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

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Hilite List Question

Post by Klaus » Sat Jun 16, 2012 11:54 am

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

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Hilite List Question

Post by townsend » Sat Jun 16, 2012 3:52 pm

Thanks Craig-- Thanks Klaus--

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

Post Reply