changing location of objects in group doesn't work

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

changing location of objects in group doesn't work

Post by makeshyft » Thu Jun 06, 2013 4:52 am

Hi everyone,

I have a scriupt that creates a group and then I create a objects in the group.

When I try to set the "loc" of the object it does not work, it snaps to the top left corner.

I've tried just about everything ... I open the group for editing (start editing), but on ending the editing snaps it back to the top left corner again.....

Here is my code,

Code: Select all


  //create the group, set size & properties
  
  create group "LocalUserListGroup"
  set the opaque of it to "true"
  set the vscrollbar of it to "true"
  //set the width of it to 500
  //set the height of it to 590
  //set loc of it to "372,455"
  set the backgroundcolor of it to "55,55,55"
  set lockLoc of it to true
  set the innerglow["color"] of it to "0,0,0"
  set the innerglow["opacity"] of it to 150
  set the innerglow["size"] of it to 20
  put it into grouplongid

  //draw avatars, custom colored frames and names
  
  local FirstLocx
  local FirstLocy
  local CurrentLocx
  local CurrentLocy
  global LocalUsersArray
  set lockLoc of grouplongid to false
  start editing group "LocalUserListGroup"
 
 // IMAGE
 
  create image LocalUsersArray[1]["User ID"]
  set the name of it to LocalUsersArray[1]["User ID"]
  set the width of it to 150
  set the height of it to 150
  set the loc of it to "100,400"
  set lockLoc of it to true
  set the filename of it to LocalUsersArray[1]["User Avatar"]
  stop editing
  set the width of grouplongid to 500
  set the height of grouplongid to 590
  set loc of grouplongid to "372,455"
  //set the lockScreen to false 
What am I doing wrong ?Thank you for any help.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

[Solved] changing location of objects in group doesn't work

Post by makeshyft » Thu Jun 06, 2013 5:07 pm

To anyone who comes across this problem in the future.

You can use the move command to move around objects inside of a group.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: [Solved] changing location of objects in group doesn't w

Post by Klaus » Thu Jun 06, 2013 6:12 pm

makeshyft wrote:To anyone who comes across this problem in the future.
You can use the move command to move around objects inside of a group.
Sure you can move object inside of groups!
What made you think you can't? 8-)

Sorry, don't understand what this has to do with your problem?

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: changing location of objects in group doesn't work

Post by jacque » Thu Jun 06, 2013 6:40 pm

Don't open the group for editing. When you set the editbackground to false afterward, the group will resize to encompass the objects within it, which can change their relative placement. Just set the locations of the objects directly, and ignore whether they are inside a group or not.

Object locations will always be relative to the top left corner of the card, even if they are inside a group.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: changing location of objects in group doesn't work

Post by makeshyft » Thu Jun 06, 2013 10:03 pm

Thank you Jacque,

and Klaus, it didn't work when I tried moving objects by setting its "loc" property. It only worked with the move command, which I didn't know, but now i know.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: changing location of objects in group doesn't work

Post by Klaus » Fri Jun 07, 2013 10:11 am

Hi Tom,

sorry, don't get this? I have been working with Livecode (and its ancestors) since 1999 and "set the loc of XYZ to X,Y" NEVER failed to work for me.
What am I missing?


Best

Klaus

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: changing location of objects in group doesn't work

Post by makeshyft » Fri Jun 07, 2013 3:56 pm

Hmmm.....I will try it again..... but I spent a good hour on it trying to set the loc of an object inside a group and it didn't move....when I had the loc of the group locked that is.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

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

Re: changing location of objects in group doesn't work

Post by dunbarx » Fri Jun 07, 2013 4:23 pm

No way locking a group locks the objects within it. And even locking objects within that group, or any objects anywhere, does not prevent a script from resetting their loc. The property only locks out user dragging.

Craig Newman

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: changing location of objects in group doesn't work

Post by bn » Fri Jun 07, 2013 6:04 pm

Tom,

what version of LiveCode are you using. There is something fishy going on.
I also get funny results using an adaption of your script. I used Tom's script to create a group and an image in that group. The image appears in the wrong place. And I can not set the loc of the image by script.

I append the stack. If someone could explain me what is going on I would be grateful.

Kind regards
Bernd
Attachments
create Image in group.livecode.zip
(6.3 KiB) Downloaded 312 times

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

Re: changing location of objects in group doesn't work

Post by dunbarx » Fri Jun 07, 2013 6:21 pm

Bernd

Using 5.4.4.

Are you saying the line:

set the loc of image "myImage" to twhere -- in btn "setLocationOfImageTo300_400"

does not work?

Mine does. Though you have to change the coordinates, since they were preset to "300,400" when the group was created, and the button sets to the same ones.

Also, could you be just a little more descriptive when setting the names of your buttons? That one above was cryptic.

Craig Newman

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: changing location of objects in group doesn't work

Post by bn » Fri Jun 07, 2013 6:40 pm

Craig,

sorry for the "cryptiness"

If, after creating the group + image by button "createGroupMakeShyft", you look at the group location, which is set to 300,400 by script and the image location which is also set to 300,400 by script but appears at the topLeft of the group then the script fails to set the image to 300,400.

In the field you see the actual location of image "myImage" after pressing button "setLocationOfImageTo300_400". Actually I can not change the location of the image by script at all. Just as Tom described.

Or are you saying that when you press button "createGroupMakeShyft" the image "myImage" is located in the middle of the group at 300,400? That is not what I see.

I tried this with Livecode 5.5.2, 5.5.4 and 6.0.2 always the same.

Thanks for looking into this

Kind regards
Bernd

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: changing location of objects in group doesn't work

Post by jacque » Fri Jun 07, 2013 6:46 pm

Interesting sample stack. The problem is the vscroll of the group. If it's set the odd behavior occurs. When I comment out that line, it works as expected.

It looks like a bug that needs to be reported.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: changing location of objects in group doesn't work

Post by FourthWorld » Fri Jun 07, 2013 6:58 pm

FWIW, if you set the boundingRect of the group to the rect of the group, the problem goes away, even with the scrollbar present.

I've seen a few cases where the boundingRect helps with object positioning withing groups, so there may be some non-obvious logic at play here that might mean it's not a bug but an intended feature, or at least a buggy side-effect of an intended feature.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: changing location of objects in group doesn't work

Post by dunbarx » Fri Jun 07, 2013 7:39 pm

I was focused on whether the image could be set by script. It can, but there is indeed a wierdness.

Richard, setting the bounding rectangle to anything but empty solves the problem.

Jacques is right about the vScroll.

Craig

makeshyft
Posts: 222
Joined: Mon Apr 15, 2013 4:41 am
Contact:

Re: changing location of objects in group doesn't work

Post by makeshyft » Fri Jun 07, 2013 7:48 pm

Hmm.... I will play around with this some more and try to nail it down, and work with the bounding rect. I did find a workaround for this, but I would prefer cleaner code.

Thanks you guys for taking the time to look at this.
Founder & Developer @ MakeShyft R.D.A - https://www.makeshyft.com
Build Software with AppStarterStack for Livecode - https://www.AppStarterStack.com
Save Time with The Time Saver's Toolbox - https://www.TimeSaversToolbox.com

Post Reply