How to move an object by double clicking the mouse button?

Hello.

I need help.

It is necessary that the box with the arrow, after being selected, moves to the cursor after double-clicking the mouse button in any part of the screen.

The box with the arrow has a logical variable, if it is true, then the red highlight effect is applied to it, if it is false, then the box has no effect.

You can select a box in two ways: hover the cursor over the box and click the mouse button, or select an area by double-clicking.

The box should move towards the cursor after double-clicking the mouse button in any free area of ​​the screen.

Tell me where the error is, this condition does not work!!!


I’m wondering if both the double clicking and regular mouse conditions are being processed. Maybe even twice once for each click. I don’t have the time to try it myself. I’ll try it later and if I come up with a solution before others, then I’ll post what I learned.

I don’t understand the double click selecting the box. Is there only 1 box? If you double click the destination then the border would be either created there or not at all. Whether there are multiple box objects or not I would only move the object if it has been selected. I think that would clear up some of the conflicts and make it a little clearer.

Also, all conditions in an event need to be true unless inside an OR condition, so you don’t to use the AND (all of the following) in your current setup.

Mouse press
Touch object
trigger once

Action toggle
(subevents)
— if true… Enable effects yes
— if false… Enable effects no

If double click, object boolean is true
Then move to cursor position and everything else

This works for me.

It still needs to handle different scenarios like maybe preventing objects from being selected if they’re moving. If there are multiple objects then maybe selecting 1 object unselects the others. Or a single click on an empty space unselects everything. Although, with the double clicking, you might need a timer so double clicking doesn’t work as an unselect.

This might work. I don’t know if there will be multiple box objects but this would pick either the one that’s selected or if none are selected, it picks the nearest one that isn’t moving.

001

  1. Disable the highlight effect at startup
    002
  2. After double-clicking the mouse (without releasing the mouse button), set values in the upper left XY variables (Var_Cur_X_UP, Var_Cur_Y_UP)
    Create a red rectangle in coordinates Var_Cur_X_UP, Var_Cur_Y_UP
    Change the transparency of the red rectangle
    003
  3. While the mouse button is not released (and we move the mouse), set the values ​​for the lower right XY coordinates (Var_Cur_X_DOWN, Var_Cur_Y_DOWN)
    004
  4. Change the scale of the red rectangle (from upper left to lower right coordinates)
    005
  5. After releasing the left mouse button, delete the red rectangle
    006
  6. For control (optional), we look at which variables are assigned to the variables Var_Cur_X_UP, Var_Cur_Y_UP, Var_Cur_X_DOWN, Var_Cur_Y_DOWN
    007
  7. Change the selection of the white cube with the arrow in accordance with the logical variable
  8. If the mouse cursor touches the White cube and the mouse button is pressed on it, then switch its logical variable
    009
  9. If the red rectangle touches the white cube, then the white cube’s variable is true (highlighted)
  10. If the logical variable of the white cube is true and in any area of the screen there is a double click of the mouse button (For example, I changed it to one click of the mouse button, in this case it works) then move such a white cube to the place where the mouse button is pressed, and change the logical variable to lie

!!! It is necessary for the last condition to work by double clicking the mouse button!!!

I remade the last action using a trick.

Comparing the variables Var_Cur_X_UP and Var_Cur_X_DOWN we get a double mouse click :wink:

Thank you for your time, everything is working :slight_smile:

1 Like

I’m glad it’s working. The RTS extension might help although it might be more than you need. IDK.