Page 1 of 1
returninfield not working?
Posted: Tue Dec 24, 2013 9:04 pm
by XNiiNJA
Hi,
I've been trying to get the "returninfield" message to work on a data grid. However, when I put code into the returninfield function on my datagrid's group, it doesn't do anything. It's like the message wasn't received or even fired in the first place. What am I doing wrong?
Re: returninfield not working?
Posted: Tue Dec 24, 2013 9:34 pm
by dunbarx
Datagrids are too big for their own good. Or rather, I use them but do not really understand them.
When you open a field in a DG, you do not actually open the field named, say "Col 3 0004". The group makes an ephemeral new field named "DataGridFieldEditor" that sits on top of that field. That is where you actually type, and that is why you do not see a returnInField message in the group script. That temporary field is not part of the group. Try this. Make a new DG, put some data in it. Make a new field and name it "dd". In the card script:
Code: Select all
on keydown var
put the target into fld "dd"
pass keydown
end keydown
Now when you type into a "cell", you will see the name of the target field, that ghost field. There is a lot of stuff going on in a dataGrid, but you will find no scripts attached to them. All messages are handled "externally", in the package of libraries that accompany the creation of the beast.
You can do certain things: again in the card script:
Code: Select all
on mouseEnter
put the target into fld "dd"
end mouseEnter
Good luck...
Craig Newman
Re: returninfield not working?
Posted: Tue Dec 24, 2013 10:38 pm
by XNiiNJA
Thanks for the insight. Is there anyway I can get that field and put a script on it or something?
Re: returninfield not working?
Posted: Wed Dec 25, 2013 12:57 am
by dunbarx
Not sure. Maybe someone else will know of a way. DG's keep theirs close by.
I tried this in the stack script, which I also made a backScript to see if anything was passed along:
Code: Select all
on newField
put random(999) into fld "dd"
end newField
on mouseDoubleUp
put random(999) into fld "dd"
end mouseDoubleUp
You get a nice new number if you create a new field in your favorite way, or double-click anywhere, but not if you let the DG make its ghost field by double clicking in a "cell". Did I mention it keeps to itself?
Craig
Re: returninfield not working?
Posted: Wed Dec 25, 2013 1:08 am
by dunbarx
I assume you still have your DG and a field "dd". I tried this in a button:
Code: Select all
on mouseUp
checkForGhost
end mouseUp
on checkForGhost
if the optionKey is down then exit to top -- a way to get out of this madness
if there is a field "DataGridFieldEditor" then
put random(999) into fld "dd"
set the textSize of fld "DataGridFieldEditor" to random(10) + 9 --do what you will to that poor field
end if
send "checkForGhost" to me in 20
end checkForGhost
Click on the button and then double-cllick in the DG. AHA! I suppose you can now do your worst to that field. But I must warn you, the DG is going to try to thwart you.
Craig
EDIT, The lesson here really is that a DG is just a complex LC gadget, made with ordinary LC controls and behaviors. And I also see that the ghost field is indeed not a member of the DG group, but it is a member of one of the subgroups: group "dgListMask", which is in turn owned by the DG group. If that helps.