Position Substack relative to mainstack

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Position Substack relative to mainstack

Post by mrcoollion » Wed Jan 04, 2017 4:37 pm

I am having troubles positioning a smaller substack relative to the position of the main stack or an object in the main stack.

Any help would be appreciated.

Regards,

Paul

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Position Substack relative to mainstack

Post by mrcoollion » Wed Jan 04, 2017 5:15 pm

Got it 8) ,

Mayby a bit elaborate but it works.
Any faster way's? Please let me know! :D

Code: Select all

   put the topLeft  of me into tsavedTopLeft // it the button that launches the substack. Can be any other object on the card.
   put item 1 of  tsavedTopLeft into tLeftMeCoordinate
   put item 2 of  tsavedTopLeft into tTopMeCoordinate
   put the TopLeft of this stack into tStackLocation
   put item 1 of  tStackLocation into tLeftCoordinate
   put item 2 of  tStackLocation into tTopCoordinate
   put -180 into tMoveLeftRight// This positions the SubStack hor-coordinate relative to the object (button that launches the substack in this case)
   put -100 into tMoveUpDown // This positions the SubStack vert-coordinate relative to the object (button that launches the substack in this case)
   add tTopMeCoordinate+tMoveUpDown to tTopCoordinate
   add tLeftMeCoordinate+tMoveLeftRight to tLeftCoordinate
   put tLeftCoordinate&","&tTopCoordinate into tSubStackLocation
   open invisible stack "theSubStackName"
   set the topLeft of stack "theSubStackName" to tSubStackLocation
   set the visible of stack "theSubStackName" to true

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

Re: Position Substack relative to mainstack

Post by Klaus » Wed Jan 04, 2017 5:35 pm

Dag Paul.

not sure I understand your problem correctly, but I would:

Code: Select all

...
## Use SCREEN coordinates directly!
put globalloc(the topLeft of me) into tsavedTopLeft

## Add H and V offset
add 180 to item 1 of tsavedTopLeft
add 100 to item 2 of tsavedTopLeft

## Set loc of substack, no need to open it invisible before!
set the topLeft of stack "theSubStackName" to tsavedTopLeft
go stack "theSubStackName"
...
Best

Klaus

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Position Substack relative to mainstack

Post by mrcoollion » Wed Jan 04, 2017 5:39 pm

LOL ... :D Knew it could be done much easier..

Bedankt !

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

Re: Position Substack relative to mainstack

Post by Klaus » Wed Jan 04, 2017 5:58 pm

Graag gedaan! :D

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

Re: Position Substack relative to mainstack

Post by dunbarx » Wed Jan 04, 2017 6:20 pm

Gesundheit.

I often locate a substack to the right of a mainstack by:

Code: Select all

...
   set the left of stack "subStack" to the right of stack "mainStack + 10
   set the top of stack "subStack" to the top of stack "mainStack"
Craig

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

Re: Position Substack relative to mainstack

Post by Klaus » Wed Jan 04, 2017 6:25 pm

dunbarx wrote:Gesundheit.
:D :D :D

mrcoollion
Posts: 738
Joined: Thu Sep 11, 2014 1:49 pm

Re: Position Substack relative to mainstack

Post by mrcoollion » Wed Jan 04, 2017 8:06 pm

Thanks Craig.... :D

Post Reply