Page 1 of 1

Grab an object outside of its group

Posted: Fri May 31, 2013 11:19 am
by Mag
Hi all,

In an iOS app, I replaced touch messages with mouse messages (I replaced touchStart, pTouchId, touchMove, touchEnd and touchRelease with mouseDown+grab and mouseUp). I done this to make code simpler, to improve speed in dragging objects and to let me test in desktop.

Unfortunately I get a problem with the grab command: when I drag a button it shows only inside its group. This is a problem because I need to drag the object on the entire card space... Any idea?

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 1:59 pm
by Klaus
Hi Mag,

if an object is part of a group, well then you have bad luck 8-)
And this has nothing to do with the GRAB command etc., it is the meaning of groups!

You will need to put that object OUTSIDE of the group or resize the group to the card size!
Sorry, definitively no other way!


Best

Klaus

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 3:33 pm
by dave_probertGA6e24
Hi,

As Klaus says - you cannot drag any object that is in a group outside of the group, but you can fake it ;)

Instead of doing a 'grab' on the actual object you want to move (when you do a mousedown), get it's loc, create a copy/clone of the object to outside of the group (or a completely new 'drag' object) and then set it's loc to that of the one in the group. Then hide the one in the group and 'grab' the new object. At the end of the drag process you can delete the old 'hidden' object and then work with the new object, or figure out how to get the object out of the group to begin with (probably something to do with relayer or suchlike!)

Remember, there are usually workarounds for most of what you might want to do.

Dave

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 3:43 pm
by Mag
Thank you so much Klaus and Dave!!

As workaround is there also the possibility to temporarily remove that object from the group? If not, I will try to implement the fake object way... :)

PS
I need something of very responsive

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 4:00 pm
by Klaus
Hi Mag,
Mag wrote:Thank you so much Klaus and Dave!!
As workaround is there also the possibility to temporarily remove that object from the group
I would simply HIDE the object from the group temporarily instead of deleting :-)


Best

Klaus

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 4:05 pm
by Mag
Sorry, I do not think I have got it right... :(

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 4:24 pm
by Klaus
Hi Mag,

what exactly are you trying to do?
I am sure it can be done :-)


Best

Klaus

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 5:46 pm
by Mag
Hi Klaus,

I have a group with 8 buttons. User can drag them.

When I use touches there is not problems: the buttons show when dragger out of the group. When I use grab, the buttons don't show when out of the group (it's just a problem of see them, because the funcion works in both the cases).

PS
Well now I undertand your post, remove is equivalent to delete in LiveCode jargon, right? Hehehe

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 6:17 pm
by Mag
PS
I just tried to temporarily resize the size of the group to bring the size of the card, unfortunately the object moves a bit '.

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 6:22 pm
by jacque
Try setting the lockLocation of the group to false, and the boundingRect of the group to the rect of the card. Then you should be able to use grab.

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 7:10 pm
by Mag
Thank you jacque! Do you know also is there is a way to back the group's boundingRect to its default size (without the need to store the size I mean)? I need to restore the bounding because I apply visual effects when move it.

Re: Grab an object outside of its group

Posted: Fri May 31, 2013 8:50 pm
by Mag
Ok, I see that the default value it's empty.
From Dictionary:
If a group's boundingRect is empty and its lockLocation is false, when you drag an object toward the boundary of the group, the group automatically expands, resizing itself to fit.
I'm in this situation now, but seems that the object is clipped the same. I continue the experiments...

BTW
Setting the boundingRect to the card size the objects are not clipped as suggested Jucque

Re: Grab an object outside of its group

Posted: Sun Jun 02, 2013 1:33 pm
by Mag
I done some tests with this code

When I need to drag objects:

Code: Select all

   set the boundingRect of the group "myGroup" to the rect of this card
   set the lockLocation of the group "myGroup" to false
When I need to change group visible in the card with a visual effect:

Code: Select all

   set the boundingRect of the group "myGroup" to empty
   set the lockLocation of the group "myGroup" to true
All seems to work fine, but when I call the first handler the values get OK, but the object start to display fine only starting from the second time I drag it... the first time it's clipped.

Re: Grab an object outside of its group

Posted: Mon Jun 03, 2013 5:37 pm
by Mag
Ok solved with a sort of workaround: I added to the group a non-opaque, disabled button and resize it to the card size when need to drag objects of the group and reduce its size when need to move the group with visual effects.

Thank you to all helped me with suggestions and info.