Trapping Arow keys in Datagrid Form

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
jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Trapping Arow keys in Datagrid Form

Post by jameshale » Wed Mar 26, 2014 4:25 am

Hi,

I have a simple data grid form where each row consists of one field.
I want to populate a field, external to the data grid with content, that depends on the row in the data grid that is selected by the mousedown event.
I can do this with the mousedown handler in the row behaviour and it works fine.

But I would also like to do the same thing when a user uses the arrow keys to move up or down the data grid.

Using the arrow keys does what it should, i.e moves up and down the grid BUT how do I trap the arrow key event to do something else as well?
In my case, do the same as is done by the already working mousedown handler.

I have tried an "on arrowkey thekey" handler in the row behaviour.
I have tried a "before arrowkey the key" handler in the row behaviour.

Neither is called (I put a BEEP in them to tell if they are.)

Can I trap the arrow key in the way I want?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Trapping Arow keys in Datagrid Form

Post by Simon » Wed Mar 26, 2014 5:08 am

Hi jameshale,
What happens when you put "on arrowkey thekey" in the dg group script?

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Trapping Arow keys in Datagrid Form

Post by jameshale » Wed Mar 26, 2014 6:03 am

nada.

I tried both "on arrowkey" and "before arrowkey" (the later as I noticed there was a handler deeper in DG for this).

In both cases I inserted both a BEEP and a BREAKPOINT in the hope that I would either hear the handler being actioned or I would stop in the handler and be able to trace.

zilch.

It was as if they were not even there.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Trapping Arow keys in Datagrid Form

Post by Simon » Wed Mar 26, 2014 6:20 am

hmmm.
I just added

Code: Select all

on arrowKey tKey
   beep
end arrowKey
to the dg group and it's beeping.

Simon
Edit; Not the row but the Custom Control DataGrid (which is a group).
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Trapping Arow keys in Datagrid Form

Post by jameshale » Wed Mar 26, 2014 6:34 am

Solved it.

Seems the handler needs to go into the script of the DG group itself.

Don't quite know why but it works.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Trapping Arow keys in Datagrid Form

Post by Simon » Wed Mar 26, 2014 7:01 am

errrr... I said that :)
Glad you got it working.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: Trapping Arow keys in Datagrid Form

Post by snm » Wed Mar 26, 2014 7:08 am

Try to trap "selectionChanged" message. It will work everytime the rów is changed.

Marek

jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 489
Joined: Thu Sep 04, 2008 6:23 am

Re: Trapping Arow keys in Datagrid Form

Post by jameshale » Wed Mar 26, 2014 12:16 pm

Sorry Simon.
Didn't see your mention of the group behaviour rather than row behaviour.
When I read it I was probably fixated on "row" and all else was invisible.
However it was probably registered unconsciously as after a while (before checking back to the forum) I looked at the group's behaviour..

So thank you

James

Post Reply