Datagrid - Detecting Return in Field

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
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Datagrid - Detecting Return in Field

Post by Simon Knight » Fri Jan 02, 2015 11:37 pm

Hi,

I would like my code to react to the return key being pressed in one of the two fields on my datagrid form. I have trapped the key press in both a custom field editor script and the script of the datagrid group but I am unable to determine which field is being edited.

Code: Select all

on returnInField
   put the short name of the target into theField
   put "Return in Field reports that the field name is " & theField & Cr after fld "debug"
    if the autotab of me then
        send "DeleteFieldEditor" to the dgControl of me in 0 seconds
    else
        pass returnInField
    end if
end returnInField
This code just populates the variable thefield with the name of the field editor. Is there a way of getting the name of the field on the datagrid ?

Simon K
best wishes
Skids

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Datagrid - Detecting Return in Field

Post by dunbarx » Sat Jan 03, 2015 4:10 am

Hi.

I only use DG table styles. If I place a handler in the group script like:

Code: Select all

on mouseUp
   put the short name of the target into fld 1
end mouseUp
I get the usual: "col 2 0001", or whatever. When you say you get the "field editor", do you mean the "ghost" field that the object creates on the fly, that is, the editable field for data entry?

Craig Newman

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid - Detecting Return in Field

Post by Simon Knight » Sat Jan 03, 2015 9:56 am

Hi Craig,

Yes, depending on where I put the code I can get either the name of the field but no detection of keydown or I get the keydown but the field is reported as the ghost fieldeditor field.

I am trying to emulate an outline app where in return in the title adds a new row/record and a return in the note field adds a return in the note text.

Simon K.
best wishes
Skids

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm

Re: Datagrid - Detecting Return in Field

Post by sritcp » Sat Jan 03, 2015 9:14 pm

Hi Simon:

May I ask where you put the code to detect the keyDown, and where to get the name of the field?

I wonder if you can save the name of the current field in a global (which is updated on closeField, say), and use it with the key information gleaned separately.

Regards,
Sri.

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid - Detecting Return in Field

Post by Simon Knight » Sun Jan 04, 2015 6:11 pm

The code snip was in a button behavior used as the CustomFieldEditor. I have tried of the target and of me and both return the field name as "DataGridFieldEditor".
best wishes
Skids

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Datagrid - Detecting Return in Field

Post by Simon Knight » Sun Jan 04, 2015 6:28 pm

I wonder if you can save the name of the current field in a global (which is updated on closeField, say), and use it with the key information gleaned separately.
Thanks it works : I added a custom property to the datagrid group and populate it with the name of the field in the row behavior handler EditValue pKey which is called when the field is selected.

Many thanks,

Simon K
best wishes
Skids

Post Reply