Forum Discussion
Drag and Drop Issue - How to disable drop targets
I am creating a fraction game where the player is dealt a card and can choose where to place the card. I disable the card once it is dropped because the player is not suppose to move the card after placing it. That all works fine. The issue is that the player can now drop another card on top of the first one and replace it, but I do not want that to happen. How can I disable the drop target once a card has been dropped on it. I've tried using triggers, but that hasn't worked either. I've attached my file. Any help would be appreciated.
- LiGPlaymakersDeCommunity Member
So... The moving the target to an empty state after its been dropped on worked initially but after recent updates and making changes it no longer works.
Has anyone found a new work around? I am working on a file with 25 drop zones...
- CharlotteHaslerCommunity Member
I just had the same problem and because the solution with the states unfortunately no longer works, I tried BenMcKenna-ba88's idea. And it works!
More precisely: I created a motion path for each drop element that has a length of 0px and is completely outside the slide. This is triggered in my version as soon as the interaction is sent (but should work in the same way as soon as the correct element has been dropped). In addition, the dropped element is set to “deactivated” so that it can no longer be moved.
You can try the interaction here
And there is also the file:
(don't be surprised about the many triggers: I use them so that only one element can be in each position and to provide non-assigned elements with the appropriate status)
- WaltHamiltonSuper Hero
Naveen,
Can the learner drag the dropped item off the target? If so, does that cause problems?
There is a sample that may help solve that problem at the bottom of this discussion:
- NaveenVerma-3edCommunity Member
I tried all the above solutions, but what works perfect for me is here :
Make new state for the Drop box and make this empty. then add individual triggers to the all correct drag boxes that.... State change of Drop box to "new state"(empty), when user drop correct drag box to the current drop box.
if you have 3 drop box and user can drop any of the 3 correct box, then add same 3 triggers on the current drag box.
Happy that its working fine for me :)
- NenadRadovic-c6Community Member
I've been struggling with this issue for days, until I finally found this comment, tried it out, and it worked for me! Thank you so much Naveen!
- ShellyBriscoe-2Community Member
Transparent layer did not work for me. Had to set the draggable objects to Disabled once correctly dropped (so they could no longer be moved), and set the drop target to a Deleted state I created, so that an additional object could not be dropped on it.
- MatthewMcCabe-aCommunity Member
Hero status warranted, been wracking my brain over this and a transparent layer works beautifully, thank you 👍
- StacyJones-bf5fCommunity Member
I’ve been struggling with this drag and drop issue for a while. I’ve been scouring the E-Learning Heroes and other parts of the interwebs for solutions. In this thread and others are snippets of suggestions and advise but I’ve yet to be able to find a comprehensive example build. So I made one. Hopefully this helps someone. Below is an (hopefully clear) explanation of the steps I took to create a drag and drop exercise that won’t allow you to drop multiple drops on the same target and won’t allow drops to be moved once they are dropped. The story file is attached so you can download and see all the triggers.
I created a Variable for each Drop Box Target, “Box1Variable”, “Box2Variable”, etc
Add 1 to each Box Variable when any Shape is dropped in. This means you have to create a trigger for all 3 shapes to adjust the variable in all 3 boxes. (9 total triggers to accomplish this)Created a “Deleted” State for each Box by creating a new state, named it “Deleted”, then actually deleted the box from the slide in that state. When the Box Variable for a given box is ≥ 1, it triggers the Deleted state. This leaves the shape that was dropped there, where it is, but won’t allow another shape to be dropped on top of it.
Created Slide Layers “Cover 1”, “Cover 2”, “Cover 3”. Each layer has a square Shape on it with a background color of grey at 80% opaque that covers the corresponding box on each slide. So the cover shape on “Cover 1” Layer covers the Box 1 Drop Target. They are each triggered to show when the corresponding Box Variable is ≥ 1. This prevents the user from clicking and dragging the Shape that was placed in the Box, around on the screen.
Submit Button default is set to “Disabled” state. When all 3 Box Variables are ≥ 1, the Submit Button changes to “Normal” state and can be clicked on.
Created “CorrectVariable” variable, which has 1 added every time the correct Shape is dropped on the correct Box. No points are added when an incorrect shape is dropped on a box. i.e. +1 when Shape 1 dropped on Box 1, but +0 when Shape 1 dropped on Box 2.
When user clicks Submit and CorrectVariable = 3, “Correct” feedback Layer is shown. When user clicks Submit and CorrectVariable < 3 then “Incorrect” feedback Layer is shown.
For reference, I’ve also included a Variable Reference box next to each Box that corresponds to the Variable for that Box, and a Variable Reference box next to the Submit button that corresponds to the CorrectVariable, so you can see how placing correct vs incorrect shapes on boxes causes the variables to change or not change. The reference variable text boxes are not necessary to the project in any way.
Each Feedback Layer has a “Back” button that will take you back and reset the slide to the initial state so you can play with the Correct and Incorrect features and watch the Variables change with different attempts.
- GillianDelvigneCommunity Member
Hi Kevin,
You have to create a variable for each drog target. You can define the variable value to 0 and change it to 1 when a correct item is dropped inside. Then you link the state of the drop target to the variable: when the variable value will change, the drop target will turn to a custom "deleted" state that you will create. :)
Hope it helps.
- rexmorCommunity Member
Ohh yeah, I forgot to add a dummy drop target. Cheers!
- RockyLittle-e27Community Member
I see what you've done there and I don't think its the best solution ... in my opinion the user should not be required to trigger a 'click event' to disable the drag tile once it has been dropped - the layers trick mentioned atop of this article is the appropriate way to set this up ...
- rexmorCommunity Member
My sample is just a prototype. You can do many scenarios from it. It is not a canned solution where you open and eats. When you open it, you need to cook based on your recipe. I am just sharing people how to fish and feed him for a lifetime. Cheers!
RE: Drag and Drop Issue - How to disable drop targets
- DeanLodes-a0bc2Community Member
I ended up using Gillian's suggestion and it works. Thank you everyone who has contributed your ideas. You're definitely a creative bunch with great suggestions.
I find it unfortunate that we all have to find these workarounds for these things.
- rexmorCommunity Member