Page 1 of 1

Resizing stack and group positions...

Posted: Mon Oct 31, 2011 2:24 pm
by Tomka
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.

Re: Resizing stack and group positions...

Posted: Mon Oct 31, 2011 7:12 pm
by Mark
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

Re: Resizing stack and group positions...

Posted: Mon Oct 31, 2011 7:44 pm
by Klaus
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

Re: Resizing stack and group positions...

Posted: Tue Nov 01, 2011 9:11 am
by Tomka
Thanks alot guys. Wont be easy but I´ll try to make a own resize-handler.

Thanks

Re: Resizing stack and group positions...

Posted: Tue Nov 01, 2011 12:48 pm
by Klaus
Hi TOm,

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


Best

Klaus