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: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
trevix
Posts: 960
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 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Klaus
Posts: 13829
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: 960
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 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9669
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”