Filter data entry on DataGrid Form

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
trevix
Posts: 581
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Filter data entry on DataGrid Form

Post by trevix » Sun Aug 16, 2020 11:37 am

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
Trevix
OSX 10.14.6 LC 9.6.0 Dp2 iOs 9.3>

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

Re: Filter data entry on DataGrid Form

Post by Klaus » Sun Aug 16, 2020 11:55 am

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

trevix
Posts: 581
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Filter data entry on DataGrid Form

Post by trevix » Sun Aug 16, 2020 12:15 pm

Thanks.
I also added this, otherwise "@" can be keyed on OSX:

Code: Select all

On OptionKeyDown then
     Beep
end OptionKeyDown
Trevix
OSX 10.14.6 LC 9.6.0 Dp2 iOs 9.3>

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7315
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Filter data entry on DataGrid Form

Post by dunbarx » Sun Aug 16, 2020 7:21 pm

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”