Hanlding Hilite

Klaus on-rev klaus at major.on-rev.com
Wed Mar 31 14:50:02 EDT 2010


Hi Andrew,

> 
> Is there a way to handle when the hilite is changed for a scrolling list
> field?
> 
> I have a scrolling list field with non-contiguous hilite. You click on a
> line in the list to toggle its hilite on or off.
> 
> Whenever a hilite is changed in that box, I want to collect what is hilited.
> 
> on hiliteChanged
> 
> put the hilitedLines of fld "CropYears" into tLines
> repeat for each item xline in tLines
> put line xline of fld "CropYears" & ":::" after sYearList
> end repeat
> put "*" after sYearList
> replace ":::*" with empty in sYearList
> answer sYearList
> 
> end hiliteChanged
> 
> This would produce a variable (sYearList) that looks like this (with 3 years
> selected):
> 
> "2009:::2010:::2011"
> 
> I want to produce this whenever the hilited years are modified.
> 
> I have not found any information on handling the change of a hilite in a
> scrolling list field.
> 
> This would seem like a pretty standard feature, no?

Use "on selectionchanged" in the script of the field!

And you can speed things up a bit with using "the selectedtext of fld xyz"
This will give you a CR separated list of the TEXt of the selected lines :-)

Like this, I dared to shorten it a bit ;-)

on selectionchanged
  put the selectedtext of fld "CropYears" into sYearList
  replace CR with ":::" in sYearList
  answer sYearList
end hiliteChanged


Best

Klaus

--
Klaus Major
http://www.major-k.de
klaus at major.on-rev.com




More information about the use-livecode mailing list