Page 3 of 4

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 9:32 am
by richmond62
Personally I'd be inclined to try INTERSECT . . .
-
Screenshot 2024-03-02 at 10.48.40.jpg

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 12:29 pm
by Zax
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. 8)

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 1:09 pm
by richmond62
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

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 1:40 pm
by Zax
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.

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 1:46 pm
by Klaus
Maybe you can create and use a "on dragenter" behavior for your 96 objects?

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 3:18 pm
by richmond62
Well, I just put something in a mouseStillDown:

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
Admittedly if that is checking whether it overlaps 96 objets that might slow things down a bit.

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 3:40 pm
by Zax
Klaus wrote:
Sat Mar 02, 2024 1:46 pm
Maybe you can create and use a "on dragenter" behavior for your 96 objects?
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 ?

Posted: Sat Mar 02, 2024 4:32 pm
by Klaus
Works fine here, but maybe a little different than what you think! :-)
See example stack...

EDIT: Removed the silly stack

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:14 pm
by Klaus
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.

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:16 pm
by Zax
Cute design ;)
But nothing is draggable with LC 9.6.x... Am I missing something?

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:27 pm
by richmond62
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:

Code: Select all

on mouseDown 
   set the dragdata["text"] to the long ID of me
   grab me
end mouseDown
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. 8)

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:28 pm
by Klaus
Drag the button on the topleft (just as its LABEL say) onto one of the colored graphics...
A dragimage might clarify this.

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:30 pm
by richmond62
Drag the button on the topleft (just as its LABEL say) onto one of the colored graphics...
Das funktioniert nicht. :?

Just tried a drag:
-
Screenshot 2024-03-02 at 18.31.22.png

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:44 pm
by Klaus
Here a really working stack, sorry for the others...

Re: Click and/or drag ?

Posted: Sat Mar 02, 2024 5:47 pm
by richmond62
Indeed that works. 8)

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.