scroll-to-letter in sorted list
MisterX
b.xavier at internet.lu
Sat Nov 12 00:10:34 EST 2005
Charles
> I'm sorry, I can't remember who posted the nifty partial
> solution to incremental searching in a sorted list in a
> field: scroll to the first item that begins with whatever
> letter the user presses. I've made a microscopic improvement
> to take care of the case in which no item begins with the
> letter pressed:
there is one in the xosmedialib - just added this week! :)
wasn't working and here's the fix!
that's a nice script ;)
local kTyped, lastkeyin
on keyup k
-- 3 seconds too much?
if lastkeyin = empty or the seconds - lastKeyin > 3 then
put k into kTyped
else
put k after kTyped
end if
put the seconds into lastkeyin
put the sorteditem of me into thisitem
if thisitem = 0 then put 2 into thisitem -- default on names
if thisitem = 1 then
get lineoffset(kTyped,me)
else
get lineoffset(tab & kTyped,me)
end if
if it = 0 then
get 1 -- or get selection before or of item chartonum(k)-1
end if
set the hilitedline of me to it
--mouseup
end keyup
cheers
Xavier
http://monsieurx.com
> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com
> [mailto:use-revolution-bounces at lists.runrev.com] On Behalf Of
> Charles Hartman
> Sent: Saturday, November 12, 2005 05:48
> To: How to use Revolution
> Subject: scroll-to-letter in sorted list
>
> I'm sorry, I can't remember who posted the nifty partial
> solution to incremental searching in a sorted list in a
> field: scroll to the first item that begins with whatever
> letter the user presses. I've made a microscopic improvement
> to take care of the case in which no item begins with the
> letter pressed:
>
>
> on keyUp theKey
> if theKey is "a" then
> set the scroll of me to 0
> exit keyUp
> end if
> put lineOffset(CR & theKey, me) into lo
> repeat while lo is 0
> put numToChar(charToNum(theKey) - 1) into theKey
> put lineOffset(CR & theKey, me) into lo
> end repeat
> set the scroll of me to lo * the effective textHeight of
> me end keyUp
>
>
> Charles
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
More information about the use-livecode
mailing list