Arrows Keys and List Fields
Devin Asay
devin_asay at byu.edu
Fri Jan 11 12:47:38 EST 2008
Hi Gregory,
On Jan 11, 2008, at 10:15 AM, Gregory Lypny wrote:
> Hello everyone,
>
> I have a list field, and as I use the Up and Down keys, I want to
> display the contents of individual lines in another field. The
> list field's handler below displays the lagged line and not the one
> that was keyed to because the selected line doesn't change until
> the pass arrowKey command is invoked and that has to happen at the
> end for the line to change.
>
> Not sure how to get what I want.
>
> Gregory
>
> on arrowKey theKey
> if theKey is "Up" or theKey is "Down"
> then
> put the value of the selectedLine of the target into fld "Display"
> pass arrowKey
> end if
> end arrowKey
The rawKeyUp message should do what you want. I've used it before to
do what you are describing. Something like this:
on rawKeyUp pWhich
if pWhich is 65364 then # down arrow
put the hilitedLine of field "list1" into currentLine
if currentLine < the number of lines in fld "list1" then
add 1 to currentLine
set the hilitedLines of field "list1" to currentLine
end if
put the selectedText of fld "list1" into fld "showSelection"
else if pWhich is 65362 then # up arrow
put the hilitedLine of field "list1" into currentLine
if currentLine > 1 then
subtract 1 from currentLine
set the hilitedLines of field "list1" to currentLine
end if
put the selectedText of fld "list1" into fld "showSelection"
else
pass rawKeyup
end if
end rawKeyUp
HTH
Devin
Devin Asay
Humanities Technology and Research Support Center
Brigham Young University
More information about the use-livecode
mailing list