Deselect entities with Ctrl-LMB.

In other words, Ctrl inverts the normal action of LMB. It is already
possible to deselect entities through the context menu, but that
can be very awkward on laptop touchpads with a crowded sketch; with
Ctrl, a misclick is easily corrected without moving cursor at all.
pull/434/head
whitequark 2019-05-24 19:11:56 +00:00
parent bd84bc1ae9
commit 6352405206
3 changed files with 14 additions and 9 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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);