Click and/or drag ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Click and/or drag ?
Personally I'd be inclined to try INTERSECT . . .
-
-
- Attachments
-
- INTERSECT GRABBABLES.livecode.zip
- (37.42 KiB) Downloaded 23 times
Re: Click and/or drag ?
Thanks richmon62, it works fine... But I forgot to specify that I would like a visual effect on (all) the possible destination areas.
So, in your example, I would like the pale blue circle to change visually when we can release the mouse to place the orange square on the target.
So, in your example, I would like the pale blue circle to change visually when we can release the mouse to place the orange square on the target.
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Click and/or drag ?
Have a go with this:
Code: Select all
on mouseDown
put empty into fld "f1"
grab me
end mouseDown
on mouseUp
if intersect(img"DRAGGER", img "t3", 5) then
put "SUCCESS" into fld "f1"
set the ink of img "t3" to blendExclusion
end if
if intersect(img"DRAGGER", img "t1", 5) then
put "WRONG" into fld "f1"
move img "DRAGGER" to 89, 86
end if
if intersect(img"DRAGGER", img "t2", 5) then
put "WRONG" into fld "f1"
move img "DRAGGER" to 89, 86
end if
end mouseUp
- Attachments
-
- INTERSECT GRABBABLES_2.livecode.zip
- (37.69 KiB) Downloaded 24 times
Re: Click and/or drag ?
Sorry if I wasn't not accurate. I would like the visual effect to be shown before the mouse is released, in order to show that the dragged element can be dropped onto the target (here, the pale blue circle).
This could be done with a loop during grab but I'm afraid it would make the movement jerky - I currently have 96 possible targets on a card.
This could be done with a loop during grab but I'm afraid it would make the movement jerky - I currently have 96 possible targets on a card.
Re: Click and/or drag ?
Maybe you can create and use a "on dragenter" behavior for your 96 objects?
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Click and/or drag ?
Well, I just put something in a mouseStillDown:
Admittedly if that is checking whether it overlaps 96 objets that might slow things down a bit.
Code: Select all
on mouseDown
put empty into fld "f1"
grab me
end mouseDown
on mouseStillDown
if intersect(img"DRAGGER", img "t3", 5) then
set the ink of img "t3" to blendExclusion
end if
end mouseStillDown
on mouseUp
if intersect(img"DRAGGER", img "t3", 5) then
put "SUCCESS" into fld "f1"
set the ink of img "t3" to blendExclusion
end if
if intersect(img"DRAGGER", img "t1", 5) then
put "WRONG" into fld "f1"
move img "DRAGGER" to 89, 86
end if
if intersect(img"DRAGGER", img "t2", 5) then
put "WRONG" into fld "f1"
move img "DRAGGER" to 89, 86
end if
end mouseUp
- Attachments
-
- INTERSECT GRABBABLES_3.livecode.zip
- (37.7 KiB) Downloaded 22 times
Re: Click and/or drag ?
That's the problem: dragDrop and dragEnd built-in messages don't seem to be triggered when a LC control is dropped onto another LC control. Yet, according to the Dictionary, the fullDragData property has a "objects" key dedicated to LC objects.
Re: Click and/or drag ?
Works fine here, but maybe a little different than what you think!
See example stack...
EDIT: Removed the silly stack
See example stack...
EDIT: Removed the silly stack
Re: Click and/or drag ?
My stack is quite rudimentary, you should add a "dragimage" (screenshot of the control to be dragged).
Seems to be the only way of "faking" a LC "grab me" kind of action.
Seems to be the only way of "faking" a LC "grab me" kind of action.
Re: Click and/or drag ?
Cute design
But nothing is draggable with LC 9.6.x... Am I missing something?
But nothing is draggable with LC 9.6.x... Am I missing something?
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Click and/or drag ?
No: you are NOT missing anything: as downloaded the stack (at least with LC 9.6.3) does NOT work).
If you add a line to the script of the "Drag me" button like this:
it can be dragged; but NOT far enough to land on any of the circles.
My stack works: well, at least for a few targets.
If you add a line to the script of the "Drag me" button like this:
Code: Select all
on mouseDown
set the dragdata["text"] to the long ID of me
grab me
end mouseDown
My stack works: well, at least for a few targets.
Last edited by richmond62 on Sat Mar 02, 2024 5:29 pm, edited 1 time in total.
Re: Click and/or drag ?
Drag the button on the topleft (just as its LABEL say) onto one of the colored graphics...
A dragimage might clarify this.
A dragimage might clarify this.
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Click and/or drag ?
Das funktioniert nicht.Drag the button on the topleft (just as its LABEL say) onto one of the colored graphics...
Just tried a drag:
-
Re: Click and/or drag ?
Here a really working stack, sorry for the others...
- Attachments
-
- drip_drop3.livecode.zip
- (2.49 KiB) Downloaded 22 times
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Click and/or drag ?
Indeed that works.
The disadvantage with your stack is that the end-user gets visual feedback when s/he performs a drag, but the "drag image" does not remain on the target.
The disadvantage with your stack is that the end-user gets visual feedback when s/he performs a drag, but the "drag image" does not remain on the target.