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

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

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

Post by glenn9 » Thu May 07, 2020 2:59 pm

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu May 07, 2020 3:09 pm

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

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

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

Post by glenn9 » Thu May 07, 2020 3:19 pm

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

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

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

Post by glenn9 » Thu May 07, 2020 3:47 pm

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

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu May 07, 2020 3:57 pm

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?

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

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

Post by glenn9 » Thu May 07, 2020 4:35 pm

Just a normal field - I hadn't appreciated the difference!

Glenn

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu May 07, 2020 4:54 pm

OK, thank you.

Post Reply