Arrows Keys and List Fields

Richard Gaskin ambassador at
Fri Jan 11 13:12:41 EST 2008

Gregory Lypny wrote:
> 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

If you trap the selectionChanged message instead of arrowKey, you'll not 
only get the message when you want it but also have an update when the 
mouse is used to, from the same handler.  You can also get the value of 
the selected line by using the hilitedText property:

   on selectionChanged
     put the hilitedText of the target into fld "Display"
   end selectionChanged

Also, the "left" and "right" arrow keys have the same automatic behavior 
as "up" and "down" respectively, so this selectionChanged handler will 
handle those as well.

  Richard Gaskin
  Managing Editor, revJournal
  Rev tips, tutorials and more:

More information about the use-livecode mailing list