Skip to content

Commit

Permalink
Merge pull request #29434 from OliBomby/change-segment
Browse files Browse the repository at this point in the history
Fix PathControlPointVisualiser eating inputs when no control points are selected
  • Loading branch information
peppy authored Aug 16, 2024
2 parents 52c1858 + 00e2101 commit e01e630
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ public void TestManualPathTypeControlViaKeyboard()
});
assertControlPointTypeDuringPlacement(0, PathType.BSpline(4));

AddStep("press alt-2", () =>
{
InputManager.PressKey(Key.AltLeft);
InputManager.Key(Key.Number2);
InputManager.ReleaseKey(Key.AltLeft);
});
assertControlPointTypeDuringPlacement(0, PathType.BEZIER);

AddStep("start new segment via S", () => InputManager.Key(Key.S));
assertControlPointTypeDuringPlacement(2, PathType.LINEAR);

Expand All @@ -309,7 +317,7 @@ public void TestManualPathTypeControlViaKeyboard()
addClickStep(MouseButton.Right);

assertPlaced(true);
assertFinalControlPointType(0, PathType.BSpline(4));
assertFinalControlPointType(0, PathType.BEZIER);
assertFinalControlPointType(2, PathType.PERFECT_CURVE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,13 @@ protected override bool OnKeyDown(KeyDownEvent e)
if (!e.AltPressed)
return false;

// If no pieces are selected, we can't change the path type.
if (Pieces.All(p => !p.IsSelected.Value))
return false;

var type = path_types[e.Key - Key.Number1];

// The first control point can never be inherit type
if (Pieces[0].IsSelected.Value && type == null)
return false;

Expand Down

0 comments on commit e01e630

Please sign in to comment.