Changing the size properties of a stack, moves its location

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 1:30 pm

I need to change the size of a stack through a script, while leaving its location in the same place, that is with the borders shrinking toward the center.

In the manual (LC8.1.9), under "revChangeWindowSize", I read:
(..while "revChangeWindowSize" shrink toward the TopLeft, ...) Setting the height and width properties leaves the center of the window in place while all four edges move inward or outward.
But this is not the case and, in case you ask, you cannot set the lockLocation of a stack.

Did I get it wrong?

Thanks
Trevix
Trevix

Klaus
Posts: 10490
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Changing the size properties of a stack, moves its location

Post by Klaus » Mon Mar 19, 2018 1:58 pm

Hi trevix,

not sure what exactly you want/need, but this works smoothly as advertised:

Code: Select all

on mouseUp pMouseButton
   put the loc of this stack into tLoc
   lock screen
   set the width of this stack to 500
   set the height of this stack to 500
   set the loc of this stack to tLoc
   unlock screen
end mouseUp
:D

Best

Klaus

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 2:16 pm

Thanks but it is not what I need.
I would like to resize a stack from the center (long story short).
I think the dictionary is wrong or there is a bug
Trevix

Klaus
Posts: 10490
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Changing the size properties of a stack, moves its location

Post by Klaus » Mon Mar 19, 2018 2:21 pm

But that is what my script does: resize from center! This is exactly what happens when you save the loc, adjust height and width and then reset ot initial location!

the loc = CENTER of stack!

Why don't you try and see yourself? 8)
Crate a 800*800 stack and run my script.

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 2:42 pm

Sorry Klaus, I may not have explained my self:

your script does keep the location of the stack, off course, but what I would like to do is having the borders of the stack to shrink or enlarge from the center, as stated in the dictionary.
If I have a control at the loc of the stack, doing your script and resizing the stack will NOT leave the loc of the control to the loc of the stack (unless I move that too, but I have other reason for not doing this).
Attachments
Schermata 2018-03-19 alle 14.37.54.png
Schermata 2018-03-19 alle 14.37.27.png
Trevix

Klaus
Posts: 10490
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Changing the size properties of a stack, moves its location

Post by Klaus » Mon Mar 19, 2018 2:52 pm

AHA! OK, you did not mention that before. :D

I'm afraid you cannot do this without moving all controls to their new (centered) position, that is how LC works. Adjusting height and width of a stack does NOT affect the locs of the controls in the stack!

But if you group the controls, that can be done with a one liner after resizing:
...
set the loc of grp "all controls" to the loc of this cd
...

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 2:54 pm

So the dictionary is wrong ?
(..while "revChangeWindowSize" shrink toward the TopLeft, ...) Setting the height and width properties leaves the center of the window in place while all four edges move inward or outward.
Trevix

Klaus
Posts: 10490
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Changing the size properties of a stack, moves its location

Post by Klaus » Mon Mar 19, 2018 2:59 pm

No, the dictionary is correct, just tested with this script:

Code: Select all

on mouseUp pMouseButton
   answer the loc of this stack
   set the width of this stack to 500
   set the height of this stack to 500
   answer the loc of this stack
end mouseUp
I got 960,600 both times with a 800*800 stack.
But that does NOT affect the locations of controls inside of the stack!

bogs
Posts: 2404
Joined: Sat Feb 25, 2017 10:45 pm

Re: Changing the size properties of a stack, moves its location

Post by bogs » Mon Mar 19, 2018 4:31 pm

Trevix, you can test this out very easily in the IDE itself. Make a stack, put some controls in the positions you want them. If you manually move the left side or bottom of the stack, the controls do not move themselves, they will always maintain their relation relative to the right and top of the stack, as Klaus says, unless you move them programmatically.
Image

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 4:52 pm

I am really having a hard time on explaining myself (sigh).

Bogs, I know that the controls don't move if you resize a stack.
On controls you can run this:

Code: Select all

put the loc of graphic "TheRect" into tLoc
set the locklocation of graphic "TheRect" to false --stretch from center
set the width of graphic "TheRect" to 50
set the height of graphic "TheRect" to 50
if the loc of graphic "TheRect"= tLoc then --is not changed
put "True" into msg
else
put "False" into msg
end if
Result is always "true" because the width of the control is changes form the center. If you change the lock location to true then the result is false.

Now forget the controls. The above is what I wanted to do with a scripted stack resize. Reading the dictionary, seems that if you change the width property of a stack, the center loc stay the same, but it is not true.
Running this:

Code: Select all

set the width of this stack to 300
always stretch from the TopLeft corner.
Trevix

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 4:56 pm

Forgot to say:
the point is that I need to change the "rect" of the stack, in order to obtain that. Is not sufficient to change width and eight.
Trevix

trevix
Posts: 389
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Changing the size properties of a stack, moves its location

Post by trevix » Mon Mar 19, 2018 4:57 pm

(..while "revChangeWindowSize" shrink toward the TopLeft, ...) Setting the height and width properties leaves the center of the window in place while all four edges move inward or outward.
Trevix

Klaus
Posts: 10490
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Changing the size properties of a stack, moves its location

Post by Klaus » Mon Mar 19, 2018 5:01 pm

Hm, what version are you using?
i am using LC 9 RC1 on a Mac and my slighly modified scripts answer 2 identical locs:

Code: Select all

on mouseUp
   answer the loc of this stack
   set the width of this stack to 500
   answer the loc of this stack
end mouseUp
If that does not work for you then, as I already wrote, if you save the loc and set it again after resizing, everything is as you want it.
Not?

bogs
Posts: 2404
Joined: Sat Feb 25, 2017 10:45 pm

Re: Changing the size properties of a stack, moves its location

Post by bogs » Mon Mar 19, 2018 6:19 pm

trevix wrote:
Mon Mar 19, 2018 4:52 pm
I am really having a hard time on explaining myself (sigh).
My apologies for the misunderstanding.
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5646
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Changing the size properties of a stack, moves its location

Post by dunbarx » Mon Mar 19, 2018 6:25 pm

Hi,

Post a screenshot of a "before" picture of a stack with a control or two, an "after" picture of what you already get, and then a final picture of what you actually want.

Craig Newman

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”