Page 1 of 1

Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 2:59 pm
by glenn9
Hi Everyone,

I'm currently struggling with this problem:

I'm successfully filtering the lines of Field 2 with the text of field 1, and when the results are displayed in field 2, I'm wanting the up/down arrow key (whilst I am still in field 1), to move up/down the displayed lines of field 2.

I've got as far as this for the down arrow key (which of course doesn't work - I'm assuming I'm not grasping the correct logic yet or have got my self muddled with the repeat loop?!)

Code: Select all

-- whilst I'm still in field 1:

on arrowkey theKey
   repeat with x = 1 to the number of lines in field 2
   	if theKey is "down" then go to line x of field 2
       	pass arrowkey
   end repeat
   
end arrowkey
Grateful for any hints etc.

Many thanks,

Kind regards,

Glenn

Re: Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 3:09 pm
by Klaus
Hi Glenn,

are these LIST FIELDS?

Hint:
We cannot GO to a line in a field, we can select (=hilite) that line or set the cursor into that line.
So not sure what you want to achieve...


Best

Klaus

Re: Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 3:19 pm
by glenn9
Thanks Klaus,

Yes, its a field with a vertical scrollbar.

When I'm typing in field 1 I'm getting results being listed in field 2 as I type as a result of the field 1 filter.

To then select one of the result lines in field 2, I can just move the mouse and click on one of the lines of field 2, but for convenience I was wanting to handle the down arrow key to hilite the respective lines in field 2 whilst I am still sitting in field 1.

I guess in a nutshell what I'm trying to achieve is getting the up/down arrow keys to work on a 'remote' field from the field in which the arrow keys are being pressed.

(I hope I've not made it now even more confusing!)

Kind regards,

Glenn

Re: Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 3:47 pm
by glenn9
Hi Klaus,

Whoa... whilst I was making a coffee the solution suddenly came to me....

Code: Select all

on arrowkey theKey
   if theKey is "down" then focus on field 2
end arrowkey
This now enables me move up/down the lines of field 2 and I now just need to figure out how to handle the hilite but I think this should be straightfoward (famous last words!)

Thanks again for responding and being a listening ear.

Kind regards,

Glenn

Re: Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 3:57 pm
by Klaus
glenn9 wrote:
Thu May 07, 2020 3:19 pm
Yes, its a field with a vertical scrollbar.
Hm, a vertical scrollbar does not make a field a LIST field! :D
So are or are these field not LIST fields?

Re: Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 4:35 pm
by glenn9
Just a normal field - I hadn't appreciated the difference!

Glenn

Re: Handling arrow key moving from one line to another in a field

Posted: Thu May 07, 2020 4:54 pm
by Klaus
OK, thank you.