From 6cf6a783066eb749ddb5e1978afcd9d199e2cd70 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Thu, 19 Nov 2026 20:36:11 -0500 Subject: [PATCH] fix(plateview): keep the selection when Ctrl is held Ctrl+click on empty space no longer clears the selected parts, so a window drag with Ctrl adds to the selection; Ctrl+Shift+click on a part now adds it too. Co-Authored-By: Claude Opus 5.5 --- OpenNest/Actions/ActionSelect.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/OpenNest/Actions/ActionSelect.cs b/OpenNest/Actions/ActionSelect.cs index 2b9dbf9f..25e1a34f 100644 --- a/OpenNest/Actions/ActionSelect.cs +++ b/OpenNest/Actions/ActionSelect.cs @@ -116,7 +116,9 @@ namespace OpenNest.Actions if (e.Button == MouseButtons.Left) { - if (plateView.SelectedParts.Count > 0) + // Ctrl adds to the selection: a click off the parts starts a window without + // clearing what is already selected. + if (plateView.SelectedParts.Count > 0 && !IsControlHeld) { var part = plateView.GetPartAtControlPoint(e.Location); @@ -201,15 +203,13 @@ namespace OpenNest.Actions if (part == null) { - plateView.DeselectAll(); + if (!IsControlHeld) + plateView.DeselectAll(); status = Status.SetFirstPoint; return false; } - if ( - Control.ModifierKeys != Keys.Control - && plateView.SelectedParts.Contains(part) == false - ) + if (!IsControlHeld && plateView.SelectedParts.Contains(part) == false) plateView.DeselectAll(); // A common-line member brings its whole group, so a drag moves the joined parts together. @@ -253,6 +253,8 @@ namespace OpenNest.Actions private RectangleF GetRectangle() => GetRectangle(Point1, Point2); + private static bool IsControlHeld => (Control.ModifierKeys & Keys.Control) == Keys.Control; + public SelectionType SelectionType { get { return Point1.X < Point2.X ? SelectionType.Contains : SelectionType.Intersect; }