Page 1 of 1

Override arrow action on DataGrid controls

Posted: Sat Jan 23, 2021 3:53 pm
by webmaster
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!!

Re: Override arrow action on DataGrid controls

Posted: Sat Jan 23, 2021 4:47 pm
by Klaus
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

Re: Override arrow action on DataGrid controls

Posted: Sat Jan 23, 2021 9:19 pm
by webmaster
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!

Re: Override arrow action on DataGrid controls

Posted: Sat Jan 23, 2021 9:38 pm
by Klaus
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.

Re: Override arrow action on DataGrid controls

Posted: Sun Jan 24, 2021 6:25 pm
by Klaus
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! :-)