Page 1 of 1

Position object under group created through script after cd was opened

Posted: Sat Dec 07, 2019 4:12 am
by JereMiami
Hey all!

I am trying to position an object directly underneath a group, where the group was created after the card was opened through script. The object seems to be unable to find the group. Is this because it was it was created after the card was opened? Is there something I need to do to have that object find that group?

--
set the bottom of x to the bottom of grp "y"" -- y is a copy of a group that was created after the card was opened.
--
Many thanks in advance!
J.

Re: Position object under group created through script after cd was opened

Posted: Sat Dec 07, 2019 10:56 am
by jmburnod
Hi,
I see a double quote in the grp name ("y"")
What do you have in x variable, a control name ?

After you posted 10 messages you will may upload your stack and that will be easier for us to help you.
Best regards
Jean-Marc

Re: Position object under group created through script after cd was opened

Posted: Sun Dec 08, 2019 3:24 pm
by dunbarx
Hi.

Not sure how you are doing this, but try an experiment. Create a new stack. make a button with this in its script:

Code: Select all

on mouseUp
   create card
   create button
   set the top of btn 1 to 400
   create field
   set the top of fld 1 to the bottom of btn 1
end mouseUp
Click on the button.

You have created a new card and new controls, and though not overlaid, which is trivial, all is well. Do I have the sequence correct?

Craig

Re: Position object under group created through script after cd was opened

Posted: Sun Dec 08, 2019 3:56 pm
by richmond62
Do you mean:

at a lower layer on the card than the group

or

positioned lower down the card than the group

when you say,

"Position object under group" (my bolding) ?

Re: Position object under group created through script after cd was opened

Posted: Sun Dec 08, 2019 7:02 pm
by SparkOut
There are lots of things that *could* be the cause of your problem, but we can't tell for sure what it might be without seeing more of your actual code that creates the group.
One other "speculation" is the one line you showed above

Code: Select all

set the bottom of x to the bottom of grp "y"
looks like the error *might* not be in finding the new group "y" but deciding what "x" is. As you have it, LiveCode will first try to interpret x as a variable, since it is not a quoted literal, and does not have an object identifier. Did you maybe? mean something like

Code: Select all

set the bottom of field "x" to the bottom of grp "y"
In any event, seeing a bit more of your script would help to find the solution.