diff --git a/CHANGELOG.md b/CHANGELOG.md index db43f2a..d285fef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,7 @@ Other new features: * New link to match the on-screen size of the sketch with its actual size, "view → set to full scale". * When zooming to fit, constraints are also considered. + * Ctrl-clicking entities now deselects them, as the inverse of clicking. * When clicking on an entity that shares a place with other entities, the entity from the current group is selected. * When dragging an entity that shares a place with other entities, diff --git a/src/mouse.cpp b/src/mouse.cpp index 028b1f9..d5edbed 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -894,7 +894,7 @@ bool GraphicsWindow::MouseEvent(Platform::MouseEvent event) { case MouseEvent::Type::PRESS: if(event.button == MouseEvent::Button::LEFT) { - this->MouseLeftDown(event.x, event.y); + this->MouseLeftDown(event.x, event.y, event.shiftDown, event.controlDown); } else if(event.button == MouseEvent::Button::MIDDLE || event.button == MouseEvent::Button::RIGHT) { this->MouseMiddleOrRightDown(event.x, event.y); @@ -909,7 +909,7 @@ bool GraphicsWindow::MouseEvent(Platform::MouseEvent event) { case MouseEvent::Type::RELEASE: if(event.button == MouseEvent::Button::LEFT) { - this->MouseLeftUp(event.x, event.y); + this->MouseLeftUp(event.x, event.y, event.shiftDown, event.controlDown); } else if(event.button == MouseEvent::Button::RIGHT) { this->MouseRightUp(event.x, event.y); } @@ -927,7 +927,7 @@ bool GraphicsWindow::MouseEvent(Platform::MouseEvent event) { return true; } -void GraphicsWindow::MouseLeftDown(double mx, double my) { +void GraphicsWindow::MouseLeftDown(double mx, double my, bool shiftDown, bool ctrlDown) { orig.mouseDown = true; if(window->IsEditorVisible()) { @@ -1281,8 +1281,12 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { default: ClearPending(); if(!hover.IsEmpty()) { - hoverWasSelectedOnMousedown = IsSelected(&hover); - MakeSelected(&hover); + if(!ctrlDown) { + hoverWasSelectedOnMousedown = IsSelected(&hover); + MakeSelected(&hover); + } else { + MakeUnselected(&hover, /*coincidentPointTrick=*/true); + } } break; } @@ -1303,7 +1307,7 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { Invalidate(); } -void GraphicsWindow::MouseLeftUp(double mx, double my) { +void GraphicsWindow::MouseLeftUp(double mx, double my, bool shiftDown, bool ctrlDown) { orig.mouseDown = false; hoverWasSelectedOnMousedown = false; @@ -1325,7 +1329,7 @@ void GraphicsWindow::MouseLeftUp(double mx, double my) { break; case Pending::NONE: - if(hover.IsEmpty()) { + if(hover.IsEmpty() && !ctrlDown) { ClearSelection(); } break; diff --git a/src/ui.h b/src/ui.h index a9d2aca..408d653 100644 --- a/src/ui.h +++ b/src/ui.h @@ -802,8 +802,8 @@ public: bool MouseEvent(Platform::MouseEvent event); void MouseMoved(double x, double y, bool leftDown, bool middleDown, bool rightDown, bool shiftDown, bool ctrlDown); - void MouseLeftDown(double x, double y); - void MouseLeftUp(double x, double y); + void MouseLeftDown(double x, double y, bool shiftDown, bool ctrlDown); + void MouseLeftUp(double x, double y, bool shiftDown, bool ctrlDown); void MouseLeftDoubleClick(double x, double y); void MouseMiddleOrRightDown(double x, double y); void MouseRightUp(double x, double y);