I want to create a simulation in which the user is asked to drag a small box ("small_box") into a larger box ("big_box"). When small_box is inside big_box and the mouse button is released, it snaps itself to the left side of big_box.
If I don't constrain the motion of small_box, the coding is straight forward. Under small_box "On User event", if item 1 of its returned value is within the bounds of big_box, I set a variable "is_in" to true, otherwise I set "is_in" to false. Then under small_box "On click", if "is_in" is true, I set the left of small_box to the left of "big_box". This ensures that small_box snaps itself to the left of big_box only when the mouse button is released.
However, if I constrain small box's motion to along the x-axis, the user may release the mouse button when the mouse is outside the bounds of small_box. When this happens, small_box does not receive the "On click" event and fails to snap itself to the left of big_box even when "is_in" is true.
Is it possible to prevent the mouse from moving beyond the bounds of small_box during dragging when the motion of small_box is constrained?