Skip to content

Commit 21c7608

Browse files
committed
Don't allow dragging object unless left mouse button was pressed down on the cell containing the object
1 parent e59e905 commit 21c7608

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/TSMapEditor/UI/MapUI.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public CursorAction CursorAction
145145

146146
private Point lastClickedPoint;
147147
private Point pressedDownPoint;
148+
private MapTile pressedDownTile;
148149

149150
/// <summary>
150151
/// Records whether the mouse was on the map UI when the left mouse button was pressed down.
@@ -405,14 +406,17 @@ public override void OnMouseOnControl()
405406
if (Cursor.LeftPressedDown)
406407
{
407408
pressedDownPoint = cursorPoint;
409+
pressedDownTile = tileUnderCursor;
408410
}
409411
else if (!Cursor.LeftDown)
410412
{
411413
pressedDownPoint = new Point(-1, -1);
414+
pressedDownTile = null;
412415
}
413416

414-
// Attempt dragging or rotating an object
415-
if (CursorAction == null && tileUnderCursor != null && Cursor.LeftDown && !isDraggingObject && !isRotatingObject && cursorPoint != pressedDownPoint)
417+
// Attempt dragging or rotating an object.
418+
// To avoid accidental dragging, this requires the cursor to move within the cell that the left mouse button was first pressed down on.
419+
if (CursorAction == null && tileUnderCursor != null && tileUnderCursor == pressedDownTile && Cursor.LeftDown && !isDraggingObject && !isRotatingObject && cursorPoint != pressedDownPoint)
416420
{
417421
var tilePosition = GetRelativeTilePositionFromCursorPosition(tileUnderCursor);
418422
var cellObject = tileUnderCursor.GetObject(tilePosition);

0 commit comments

Comments
 (0)