Trigger Help For Drag and Drop interaction

Oct 13, 2021

Hello Everyone, 

I'm working on an interaction and my triggers aren't behaving how I thought they would. 

What I'm trying to do:

The user drags the numbered circles onto the the drop circles. Then once the numbered circles are dropped correctly, two triggers will occure. First, the state of the rectangle would change. Second, a bar would appear in the battery. The order that the numbered items are dropped should not matter. 

What's happening: 

I drag the first numbered item- the state of the rectangle changes and the first bar appears in the battery. This is exected. 

Then I drag the second numbered item. The state of the rectangle changes (expected behavior), but the bars in the battery jumpt to all four. 

Then drag the remaining numbered items. The states of the rectangles change, but the battery remains at 4 bars. 

Attached are screenshots of the interaction layout, triggers for the second drop item, and the form view for the drag and drop.

Does anyone have any thoughts on what I have configured incorrectly that's resulting in the battery bar jumping from 1 to 4 and skipping 2 and 3? 

Thanks, in advance, for your thoughts. 

3 Replies
Scott Wiley

The trigger that sets the battery to battery 1 state does not include a condition, as the following ones do. But even without one it doesn't seem to do what you want.

If you follow through the logic, it would run through the current order and quickly get to 4.

  1. Change battery to 1
  2. Change battery to 2 if currently at 1 - it is so...
  3. Change battery to 3 if currently at 2 - it is so...
  4. and so on.

 

Instead, you might try creating a new number variable to add up the drops (drop_counts).

Then another trigger to change the state of battery to a new state when drop_count changes if ... etc.

Then each drop adds 1 to drop_count with a condition that it doesn't exceed max and maybe have to check that that object hasn't been dragged/dropped before I suppose.

Hope that helps get you going in the right direction.

Walt Hamilton

Scott is right. The triggers are cascading; all of them are executed each time an item is dropped, and each one finds the state, not as it was when it was dropped, but as it is changed by the previous trigger.

The easiest way to correct this is to reverse the order of the triggers that change the state of the battery bar:

Change to 4 when dropped if state is 3

Change to 3 if state is two, etc

That way if #3 trigger increases the state to 3, it is too late for #4 trigger to also increase it.