Grab an object outside of its group

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
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Grab an object outside of its group

Post by Mag » Fri May 31, 2013 11:19 am

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?
Last edited by Mag on Fri May 31, 2013 1:01 pm, edited 1 time in total.

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

Re: Grab an object outside of its group

Post by Klaus » Fri May 31, 2013 1:59 pm

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

dave_probertGA6e24
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 328
Joined: Mon Dec 05, 2011 5:34 pm
Contact:

Re: Grab an object outside of its group

Post by dave_probertGA6e24 » Fri May 31, 2013 3:33 pm

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
Coding in the Sun - So much Fun.
Visit http://electronic-apps.info for released App information.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Fri May 31, 2013 3:43 pm

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

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

Re: Grab an object outside of its group

Post by Klaus » Fri May 31, 2013 4:00 pm

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

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Fri May 31, 2013 4:05 pm

Sorry, I do not think I have got it right... :(

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

Re: Grab an object outside of its group

Post by Klaus » Fri May 31, 2013 4:24 pm

Hi Mag,

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


Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Fri May 31, 2013 5:46 pm

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

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Fri May 31, 2013 6:17 pm

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 '.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Grab an object outside of its group

Post by jacque » Fri May 31, 2013 6:22 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Fri May 31, 2013 7:10 pm

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.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Fri May 31, 2013 8:50 pm

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

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Sun Jun 02, 2013 1:33 pm

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.

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Grab an object outside of its group

Post by Mag » Mon Jun 03, 2013 5:37 pm

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.

Post Reply