Arrows Keys and List Fields

Devin Asay devin_asay at byu.edu
Fri Jan 11 13:55:19 EST 2008


On Jan 11, 2008, at 11:12 AM, Richard Gaskin wrote:

> 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.

Rube Goldberg is spinning in his grave! Why would you want a short,  
elegant solution when you could have a complicated one that took you  
an hour to perfect!

;-)

Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University




More information about the use-livecode mailing list