Grab everything
Moderator: Klaus
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Grab everything
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.
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.
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
Enhancement Request: 12397
"Grab a control by name"
"Grab a control by name"
Re: Grab everything
Richmond.
Intrigued, I made two buttons and grouped them. In the group script I have:
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
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
Craig
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
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".
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.
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".
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.
Re: Grab everything
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
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
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
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
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
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
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.
But I don't see how that is going to allow me to grab something that my mouse cursor is not within.
Re: Grab everything
I thought:
Kind regards
Bernd
that is what revTools and gridDrawer are doing....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.
Kind regards
Bernd
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
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.
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
Now, something very odd has happened:
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.
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.
Re: Grab everything
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
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
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Grab everything
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.
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.
Re: Grab everything
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
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
Re: Grab everything
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
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