scrolling to a line

Charles Hartman charles.hartman at conncoll.edu
Sun Nov 13 11:08:18 EST 2005


I've modified Xavier's modification of my modification of  
(somebody's??) code to search incrementally in a sorted list field.  
(This version, unlike Xavier's, assumes the whole line in the field  
is the sorted item.)

But it doesn't solve one problem: suppose the user starts typing a  
string that doesn't appear in the list? If the first few letters  
match something, this scrolls to pretty close. But suppose nothing  
starts with 'Q' and the user starts by typing a 'q'? The list won't  
scroll at all. What would be nicer would be to scroll to the place  
where an item beginning with 'q' *would* be if there were one. I've  
only thought about it for a few minutes, but it's already given me a  
headache. Any clues?

local kTyped, lastKeyTime
on keyUp theKey
     if lastKeyTime is empty or the seconds - lastKeyTime > 3
     then put theKey into kTyped
     else put theKey after kTyped
     put the seconds into lastKeyTime
     put lineOffset(CR & kTyped, me) into lo
     if lo is not 0
     then set the scroll of me to lo * the effective textHeight of me
end keyUp

Charles Hartman



More information about the use-livecode mailing list