Page 1 of 1
How to test whether a data grid field editor is open?
Posted: Thu Oct 24, 2019 10:05 pm
by MichaelBluejay
I scripted my Data Grid to delete the selected row when the user presses the Backspace key. That has the unintended effect of deleting a row even if the user has opened a cell for editing. So, how can I check whether a cell is open for editing?
I thought I could set a "notOkayToDelete" flag in the on preOpenFieldEditor handler, but I don't know how to check for the editor closing so I can clear that flag. closeFieldEditor is sent only if the field contents have changed, and there seems to be no message sent if the editor is closed with no changes.
Re: How to test whether a data grid field editor is open?
Posted: Fri Oct 25, 2019 3:07 am
by dunbarx
Michael.
Fields in DG's do not open for editing. A separate "phantom" field is made visible, and sized and placed over the field of interest. So the topLeftMost field is named "Col 1 0001", but it is that other field that you see with the blinking cursor.
Trevor DeVore created the dataGrid. He is on this forum. Perhaps he might have some insight.
Trevore?
Craig
Re: How to test whether a data grid field editor is open?
Posted: Fri Oct 25, 2019 5:01 am
by MichaelBluejay
Aha! That'll work:
Code: Select all
on backspaceKey
if the short name of focusedObject() is "DataGridFieldEditor" then pass backspaceKey
else [delete the line]
end backspaceKey
Thanks, Craig.
Re: How to test whether a data grid field editor is open?
Posted: Fri Oct 25, 2019 2:06 pm
by dunbarx
Michael.
I knew it would be fun to have you around
And I never knew until now that the "phantom" field was created for each instance of use, not merely socked away and shown. I did it this way, clicking and then typing in a cell in a tiny DG:
Code: Select all
on rawKeyDown
repeat with y = 1 to the number of flds
put the name of fld y into line y of fieldList
end repeat
breakPoint
end rawKeyDown
If you click outside a "cell" that contains data, there is no phantom. If inside, you see it. How did you do it?
Craig
EDIT:
It occurred to me that an easy way to test that theory would be to search for the word "create" in the DG. There is no such command.

Re: How to test whether a data grid field editor is open?
Posted: Fri Oct 25, 2019 8:27 pm
by MichaelBluejay
Code: Select all
on idle
put the name of the focusedObject
end idle
Heh.