returninfield not working?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
XNiiNJA
Posts: 2
Joined: Tue Dec 24, 2013 8:57 pm

returninfield not working?

Post by XNiiNJA » Tue Dec 24, 2013 9:04 pm

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?

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

Re: returninfield not working?

Post by dunbarx » Tue Dec 24, 2013 9:34 pm

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

XNiiNJA
Posts: 2
Joined: Tue Dec 24, 2013 8:57 pm

Re: returninfield not working?

Post by XNiiNJA » Tue Dec 24, 2013 10:38 pm

Thanks for the insight. Is there anyway I can get that field and put a script on it or something?

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

Re: returninfield not working?

Post by dunbarx » Wed Dec 25, 2013 12:57 am

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

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

Re: returninfield not working?

Post by dunbarx » Wed Dec 25, 2013 1:08 am

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.

Post Reply