Grab everything

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Grab everything

Post by richmond62 » Wed May 07, 2014 6:34 pm

Today I tried this:

grab group "RL"

and it didn't work.

This meant I spent an awful long time because I wanted to click on a group which would then CLONE itself, rename the clone (so far so good)
and then the clone would be draggable and droppable without my having to mouseUp.

You can get a "deeper" understanding of what this involve by looking at my "Scratch clone" here: http://forums.runrev.com/viewtopic.php?f=25&t=20290

A feature enhancement to be able to grab any control by name would be a super thing.
Last edited by richmond62 on Wed May 07, 2014 6:39 pm, edited 1 time in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Wed May 07, 2014 6:38 pm

Enhancement Request: 12397

"Grab a control by name"
LC_gadfly_banana.png

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Grab everything

Post by dunbarx » Wed May 07, 2014 7:32 pm

Richmond.

Intrigued, I made two buttons and grouped them. In the group script I have:

Code: Select all

on mouseDown
   grab the owner of the target
end mouseDown
The owner being the enclosing group, of course. This works fine; the group tracks the mouse pointer when I drag. And I have no problem grabbing a group explicitly. What happened in your test?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Wed May 07, 2014 7:44 pm

Aah.

The problem is that I clicked on one control, cloned it, renamed the clone and wished to drag my mouse with the clone following it rather than the one I clicked down on.

I am uploading a stack to show what I mean: it contains 2 images; the red one is called "red" and the blue one "blue".
grab.zip
Example stack
(4.08 KiB) Downloaded 152 times
The red one contains this script:

on mouseDown
grab img "blue"
end mouseDown

and the blue one:

on mouseDown
grab img "red"
end mouseDown

and they don't work, and that's a problem.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Grab everything

Post by dunbarx » Wed May 07, 2014 8:21 pm

Richmond.

I see. The grab command requires that the mouse pointer be within the rect of the control to be grabbed.

So what you really want is to eliminate that restriction, so that you can drag a "remote" control. (sorry for that). You can always kluge this, but I see the point of your post.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Wed May 07, 2014 8:23 pm

I like your '"remote" control' a lot :)

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab everything

Post by bn » Wed May 07, 2014 8:47 pm

Hi Richmond,

have a look at stack "revTools" how they do it.

I "lifted" the code from there and adapted it in
http://livecodeshare.runrev.com/stack/757/GridDrawer

look at the script of button "DragDropBehavior"

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Wed May 07, 2014 8:49 pm

That looks like a very nifty tool.

But I don't see how that is going to allow me to grab something that my mouse cursor is not within.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab everything

Post by bn » Wed May 07, 2014 8:57 pm

I thought:
...because I wanted to click on a group which would then CLONE itself, rename the clone (so far so good)
and then the clone would be draggable and droppable without my having to mouseUp.
that is what revTools and gridDrawer are doing.

Kind regards
Bernd

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Wed May 07, 2014 9:13 pm

unGrid.png
Here is a stack with one img "blue.png" and I have
dragged your grid, set at a spacing of 10 to the stack.

Now, "blue.png" contains this script:

on mouseDown
clone me
set the name of the last img to "XX"
grab img "XX"
end mouseDown

and on execution, indeed it is the new image "XX" that is grabbed.

However I am unable to inspect the script in the button "DragDropBehavior"
so do not entirely understand what is going on.

On Linux running XFCE as a Window manager the gird appears white,
and the explanatory text field needs a vertical scrollbar.
needsAscrollbar.png

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Wed May 07, 2014 9:41 pm

Now, something very odd has happened:
Bunny.png
I set up another stack containing an image "Bunny" with this script in the image:

on mouseDown
clone me
set the name of the last image to "Cony"
grab image "Cony"
end mouseDown

and the GridDrawer object has been dragged onto the stack.

The new image "Cony" is NOT grabbed.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab everything

Post by bn » Wed May 07, 2014 10:06 pm

Richmond,

whatever happened, I have no idea what is going on. It has nothing to do with gridDrawer, as far as I see.

What I have done is to take your stack and copied the button "dragDropBehavior" to your stack. Then I have set the behavior of image "bunny.png" to the long id of the button "dragDropBehavior". (this happens on preopencard, in case you change the name of the stack. Then you either reopen the stack or go another card and return to your first card.)

Now you can drag-drop bunnies all around, just not onto the stack where bunny lives. I think that would be akin a palette where you grab elements.

Kind regards
Bernd
Attachments
BUNNY_0_1BN.livecode.zip
(26.04 KiB) Downloaded 145 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10081
Joined: Fri Feb 19, 2010 10:17 am

Re: Grab everything

Post by richmond62 » Thu May 08, 2014 7:24 am

That's wonderful.

However, this does not stop me thinking that this sort of thing:

grab button "XYZ"

wouldn't be a great advantage.

A card script could contain this:

on mouseDown
grab btn "ABC"
end mouseDown

while the utility of this may not be immediately obvious it could
solve some of those problems where end-users blindly click in a
window.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab everything

Post by bn » Sat May 10, 2014 1:39 am

Richmond,

here is a stack that has "template" groups from which you can pull off clones to the current card. The template uses a behavior button to do the cloning etc. After cloning the behavior button is deleted from the clone.
You can exchange the objects in the template group to an object of your choice.

I don't know if this is what you want. But this could conceivably be used to do a "tear-off" type of palette on the card. If you want to clone to another stack you would have to use "Bunny_0_1BN.livecode" posted above.

If you feel uneasy with the behavior button I have a version without behavior button but there is more code left over from the cloning. Just ask.

Kind regards
Bernd
Attachments
cloneAndGrab_0_2.livecode.zip
(16.32 KiB) Downloaded 150 times

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: Grab everything

Post by bn » Sat May 10, 2014 11:40 am

oops,

an update: the stack "cloneAndGrab_0_2.livecode" accidentally did not remove the behavior script from the cloned group.

Here improved stack, also there is an option in the behavior script of the template to remove enclosing group from cloned object. The code is currently blocked and commented.

If that would be of interest to "tear-off" just the object without group I could do that.

Kind regards
Bernd
Attachments
cloneAndGrab_0_3.livecode.zip
(16.47 KiB) Downloaded 157 times

Post Reply