Changing the size of objects

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
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Changing the size of objects

Post by phaworth » Tue Mar 09, 2010 10:14 pm

It seems that if I change the width or height of an object, other location properties change automatically. Same thing if change the left, top, bottom, or right. For instance, if I change the width of an object, it's left property changes by half the adjustment I made to the width, if I change the height of an object, it's top changes similarly.

This seems like totally arbitrary behaviour and I'm hoping that someone can point me to a way to prevent it from happening since I have not yet come across a single situation where I wanted this to happen. I thought maybe the "lock size and position" option in the inspector would prevent that behaviour but it doesn't.

Unless I write extra code, this can lead to unfortunate happenings. For example, I changed the height of a stack depending on its data contents and the automatic adjustment of the top location caused the top of the stack to be above the top of the screen! I closed it using the message box but if that happened in a standalone app, it would be a big problem.

Thanks for any advice,

Pete

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

Re: Changing the size of objects

Post by Klaus » Wed Mar 10, 2010 9:16 am

Hi Pete,

I am afraid there is no way to avoid a bit more scripting!

I got used to do this:
...
lock screen
put the loc of btn "xyz" into oldloc
# change widht/height etc...
# more changes...
set the loc of btn "xyz" to oldloc
unlock screen
...
You get the picture.


Best

Klaus

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

Re: Changing the size of objects

Post by dunbarx » Wed Mar 10, 2010 6:01 pm

Klaus has a point (no pun intended), in that a little scripting will be required.

But what I am hearing is that you want to lock the topLeft of and object. This will keep it visually "in place" while allowing it to grow in a "normal" way, that is, down and to the right.

So take his script and substitute "topLeft" for "loc.

Craig Newman

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Changing the size of objects

Post by phaworth » Wed Mar 10, 2010 6:34 pm

Thanks Klaus and Craig. I was really hoping there'd be a way to avoid scripting but I guess in the general scheme of things this isn't too much code.

I love using Rev to develop but every now and then something crops up that makes me wonder just what the original designers were thinking!

Pete

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

Re: Changing the size of objects

Post by dunbarx » Thu Mar 11, 2010 3:25 pm

I think most of the behavior is logical. If you have an object located somewhere, and you change its width, IMHO it ought not to change its loc. It gets fatter, but stays where it is, if you know what I mean.

You actually want to change its "right", an explicit option open to you, but you originally interpreted such a change as naturally arising from a change in width. You just need to get your head around the fact that there are descriptors for any purpose.

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: Changing the size of objects

Post by phaworth » Thu Mar 11, 2010 5:22 pm

You're right, I didn't know about some of these properties but I still think it's weird that if I change the height of a stack, I want the top and the bottom to change arbitrarily by half the amount of the height change, unless there's an option to define whether that happens or not.

I thought the dontResize property was going to solve this issue since it stops this automatic adjustment behaviour, eg if it is true and I change the right of an object, the left stays the same and the width changes. But unfortunately, it appears that property is not available for stacks - there is a checkbox in the inspector for a stack but it doesn;t seem to make any difference whether it's checkd or not and if I try to set it in a scrip I get an error saying ti can't be set.

Anyway, thanks for the code to control this. I don;t have many places where I want to do this so it's not a lot of extra code - but I don't think any extra code should be required :-)

Pete

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”