Override arrow action on DataGrid controls

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
webmaster
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 81
Joined: Mon May 09, 2011 3:01 pm

Override arrow action on DataGrid controls

Post by webmaster » Sat Jan 23, 2021 3:53 pm

I am building a user interface that includes two DataGrid form components in a card. I would like to use "on arrowKey" at the card level to trigger some specific actions. However, whenever the user hits an arrow Up or Down, the DataGrid component also acts on the message (by highlighting the previous or next row). I would like to disable / intercept / override this arrow action on the DataGrid.

I have tried a couple things, without success.
1) I put an "on arrowKey" handler on the Group that contains the DataGrid with a script line of 'pass arrowKey'
2) I put an "on arrowKey" handler on the Group that contains the DataGrid with a script line of 'send "arrowKey pKey" to the current card"
While I'd hoped these would handle the message and prevent it from being handled by the DataGrid, they did nothing. The DataGrid continues to move previous row or next row when the Up/Down arrow keys are pressed.

Any suggestions on how I can override the arrow key behavior on DataGrid forms?

Thank you!!

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Override arrow action on DataGrid controls

Post by Klaus » Sat Jan 23, 2021 4:47 pm

Hi webmaster,

datagrids have a set of their own commands, so add this "dummy" handler to the script of the datagrid group:

Code: Select all

on dgarrowkey tKey
   ##
end dgarrowkey
Tested and works! :D


Best

Klaus

webmaster
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 81
Joined: Mon May 09, 2011 3:01 pm

Re: Override arrow action on DataGrid controls

Post by webmaster » Sat Jan 23, 2021 9:19 pm

Thanks Klaus!! Your solution works great.

I double checked and the "dgarrowKey" command isn't in the LiveCode directory. Is there some way I should submit that as a documentation 'bug' ... or is there already a list somewhere of all the special/secret DataGrid commands.

Again, thanks!

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Override arrow action on DataGrid controls

Post by Klaus » Sat Jan 23, 2021 9:38 pm

My pleasure!

Not sure this is a bug, since all the gazillion Rev specific functions/commands
are also not listed in the dictionary. Remember: LC is written in LC! :D

I peeped into the datagrid library the "Tools/Toolset/libraries" subfolder of LC.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Override arrow action on DataGrid controls

Post by Klaus » Sun Jan 24, 2021 6:25 pm

You can also list all LC stacks in the project browser to peep their scripts etc., select "Show IDE Stacks in Lists" from menu "View"
Beware, there are a LOT of them! :-)

Post Reply

Return to “Talking LiveCode”