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!
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.
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 ?
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?
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.
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.
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".
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.