Arrows Keys and List Fields

Eric Chatonet eric.chatonet at sosmartsoftware.com
Fri Jan 11 12:35:01 EST 2008


Hi Gregory,

Le 11 janv. 08 à 18:15, Gregory Lypny a écrit :

> 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

You have to ways:

1. Sending in time:

on arrowKey pKey
   switch pKey
   case "up"
   case "down"
     send "MoveLine" to me in 10 milliseconds
     pass arrowKey
   end switch
end arrowKey
---------------------------------
on MoveLine
   put the selectedText of fld "List"  into fld "Display"
end MoveLine

2. Handling arrowKey by yourself:

on arrowKey pKey
   local tHilitedLine
   -----
   put the hilitedLine of fld "List" into tHilitedLine
   switch pKey
   case "up"
     if tHilitedLine = 1 then exit arrowKey
     set the hilitedLine of fld "List" to tHilitedLine - 1
     break
   case "Down"
     if tHilitedLine = the number of lines of fld "List" then exit  
arrowKey
     set the hilitedLine of fld "List" to tHilitedLine + 1
   end switch
   put the selectedText of fld "List" into fld "Display"
end arrowKey

Hope this helps :-)

Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the use-livecode mailing list