Resizing stack and group positions...

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
Tomka
Posts: 59
Joined: Mon Apr 18, 2011 7:30 pm

Resizing stack and group positions...

Post by Tomka » Mon Oct 31, 2011 2:24 pm

Hi there,

I already read that the position of a grp/img will be resetted if I resize a stack. Further I read that I have to lock size and position to prevent this. But I got a problem with that.

In my little teststack I got a single picture which contains the following script:

Code: Select all

on mousedown
   set the LockLocation of me to false
   grab me
   set the LockLocation of me to true
end mousedown
The drag&drop works fine but when I resize the stack the img-position will be resetted. I want that the image will be shown on his relative stackposition after rsizing the stack (I use the geometry manager). For example, if I drag the image to middle of the stack and resize the stack, the img shall already be in the middle of the stack.

Edit: I tested a bit more. It seems that it works when I only use the geometry manager for changing the horizontal position of the image. But if I want to change both coords (x and y) when the stack is reasized the image will be resetted to the position where it was before I drag it.

Any ideas?

Thanks alot Thomas


note: I tested it with Livecode 4.6.3 on windows 7.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Resizing stack and group positions...

Post by Mark » Mon Oct 31, 2011 7:12 pm

Hi Thomas,

I assume you are using the geometry manager (in the inspector). The GM often causes problems. For example, if you change the location of an object with messages locked, GM will get confused and may mess up your entire interface.

Ultimately it is easier and safer to write your own geometry script in a resizeStack handler. If necessary, this will allow you to read and adjust the locations and sizes of objects in real time. However, if you continue to read the current location, you may run into problems again due to rounding.

It would be best to base your own geometry script on fixed original positions at any time. If the user changes the position of an object manually, you'll need to store that new position somewhere to base your script on.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

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

Re: Resizing stack and group positions...

Post by Klaus » Mon Oct 31, 2011 7:44 pm

Hi Thomas,

yep, the "resizestack" message comes with four (4) parameters:
on resizestack new_width,new_height,old_width,old_ height
...
So you can surely do your calculations for the new loc of objects from this.


Hint:
No need to toggle the "lockloc"!

Code: Select all

## This works fine, lockloc or not:
on mousedown
   grab me
end mousedown
"Locloc" = true will only prevent objects from resizing after one hast left the current card and comes back.
I'm sure you have experienced something like this with images, everybody has! :-D


Best

Klaus

Tomka
Posts: 59
Joined: Mon Apr 18, 2011 7:30 pm

Re: Resizing stack and group positions...

Post by Tomka » Tue Nov 01, 2011 9:11 am

Thanks alot guys. Wont be easy but I´ll try to make a own resize-handler.

Thanks

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

Re: Resizing stack and group positions...

Post by Klaus » Tue Nov 01, 2011 12:48 pm

Hi TOm,

yep, it is a bit of work, but definitvely worth it! :)


Best

Klaus

Post Reply