Page 1 of 1

Filter data entry on DataGrid Form

Posted: Sun Aug 16, 2020 11:37 am
by trevix
I am having some problem on filtering the user input keys for a Datagrid Form.
This, on the script of the editable field of the row template, does not intercept the keydown.

Code: Select all

on keyDown inKey
     if inkey is not in "0123456789abcdefghijklmnopqrstuvwxyz" OR the number of chars of me > 16 then
          beep
     else
          pass keyDown
     end if
end keyDown
One way to do it would be to put the script on the DG group.
But how do I refer to the field, in order to calculate how many chars have been inserted?
Is there a way?
Thanks

Re: Filter data entry on DataGrid Form

Posted: Sun Aug 16, 2020 11:55 am
by Klaus
Buongiorno Trevix,

use THE TARGET!

Code: Select all

on keyDown inKey
   if inkey is not in "0123456789abcdefghijklmnopqrstuvwxyz" OR the number of chars of the target > 16 then
      beep
   else
      pass keyDown
   end if
end keyDown
Tested and works! :-)


Best

Klaus

Re: Filter data entry on DataGrid Form

Posted: Sun Aug 16, 2020 12:15 pm
by trevix
Thanks.
I also added this, otherwise "@" can be keyed on OSX:

Code: Select all

On OptionKeyDown then
     Beep
end OptionKeyDown

Re: Filter data entry on DataGrid Form

Posted: Sun Aug 16, 2020 7:21 pm
by dunbarx
Just so you know, the fields in a DG are named:

Code: Select all

"Col 1 0001", "Col 2 0001",...
"Col 1 0002", "Col 2 0002",...
I have found it useful now and then to reference DG fields directly.

Craig