Can LC get Loc of a group with respect to group not stack? - Solved

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

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Can LC get Loc of a group with respect to group not stack? - Solved

Post by DR White » Fri May 15, 2020 5:56 pm

Can LC get Loc of a group "test" with respect to group "ScrollArea" not stack?


I am using a scrolling group "ScrollArea" which has a height of 2000.
Group "Test" is a group within group "ScrollArea".
My stack height id 1024.

The code within group "Test" is :
on mouseUp
put loc of me into tLocMe
answer "Locaton = " & tLocMe
end mouseUp

When I touch the group "Test" that is near the bottom of group "ScrollArea",
it displays the location with respect to the stack, not the group "ScrollArea".

Is there a way to get the location the group "Test" with respect to the group "ScrollArea"?
Thanks,

David
Last edited by DR White on Sat May 16, 2020 8:43 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Can LC get Loc of a group with respect to group not stack?

Post by richmond62 » Fri May 15, 2020 8:10 pm

Probably missing something. 8)
-
Screenshot 2020-05-15 at 22.08.56.png

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

Re: Can LC get Loc of a group with respect to group not stack?

Post by FourthWorld » Fri May 15, 2020 8:38 pm

Groups have hScroll and vScroll properties, which are the number of pixels the group has been scrolled to on the horizontal and vertical axes, respectively. Also affecting interior coordinates will be the group's borderWidth and margins.

So to find a location of an object relative to its parent group, get the object's location and add the vScroll to the first item and the yScroll to the second. If your group has non-zero margins subtract those from the scroll values, along with the borderWidth of the group.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Can LC get Loc of a group with respect to group not stack?

Post by DR White » Fri May 15, 2020 9:16 pm

Thanks for the Guidance,

David

Post Reply