arrowkey and selectionchanged in a list field

David Glasgow david at dvglasgow.wanadoo.co.uk
Sat Jun 23 06:15:53 EDT 2007


I have a list field containing the names of JPGs.  I want the  
selected image displayed.  This is easy using mouseup or  
selectionchanged to trigger the appropriate URL being prepended to  
the filename, and the file displayed correctly.

However, I wanted users to be able to arrow up and down through the  
field, and the image to change just as if the selection had changed  
by being clicked on.  Unfortunately, selectionchanged is not sent if  
the selection  is changed via arrow keys.  This is a bit sad, but  
documented as normal behaviour.  This means you need to catch  
arrowkey, and then script accordingly.

I was surprised to discover that the selectedline reported in this  
way seems to lag one behind the actual selected line, and display an  
image adjacent to the correct one.   I put the script in a group  
containing the list field, so I expected the selection to have  
changed by the time the message reached the group.  But it doesn't.   
Que pasa?

I have worked around it by adding or subtracting one from the  
reported selectedline in a switch case structure, but then had to add  
script to test whether the tnewselectedline variable would be taken  
out of range by the calculation.  Happy to have got it working, but I  
can't believe there isn't a better way of doing things (- isn't there  
always in Rev?).

If the selection change by arrow key triggered the selectionchanged  
message, my cludge wouldn't be needed at all.  What have other folks  
done to achieve the same thing?



Best Wishes,

David Glasgow
Carlton Glasgow Partnership

http://www.i-psych.co.uk




More information about the use-livecode mailing list