Skip to content

Commit 820a7ff

Browse files
committed
tweak double click selection behavior
1 parent 46840cf commit 820a7ff

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/polyscope.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,13 @@ void processInputEvents() {
522522
bool anyModifierHeld = io.KeyShift || io.KeyCtrl || io.KeyAlt;
523523
bool ctrlShiftHeld = io.KeyShift && io.KeyCtrl;
524524

525-
if (!anyModifierHeld && io.MouseReleased[0]) {
525+
// NOTE: there is annoyance here that we use single click for picking, and double click
526+
// to recenter the view. However, there's no way to distingish which is happening
527+
// after the first click without waiting. After trying several solutions, it feels
528+
// best to let the first click always do a pick, but clear the selection if a
529+
// double click comes in.
530+
531+
if (!anyModifierHeld && (io.MouseReleased[0] && io.MouseClickedLastCount[0] == 1)) {
526532

527533
// Don't pick at the end of a long drag
528534
if (dragDistSinceLastRelease < dragIgnoreThreshold) {
@@ -541,10 +547,12 @@ void processInputEvents() {
541547
}
542548

543549
// Double-click or Ctrl-shift left-click to set new center
544-
if (io.MouseDoubleClicked[0] || (ctrlShiftHeld && io.MouseReleased[0])) {
550+
if ((io.MouseReleased[0] && io.MouseClickedLastCount[0] == 2) || (io.MouseReleased[0] && ctrlShiftHeld)) {
545551
if (dragDistSinceLastRelease < dragIgnoreThreshold) {
546552
glm::vec2 screenCoords{io.MousePos.x, io.MousePos.y};
547553
view::processSetCenter(screenCoords);
554+
resetSelection(); // the single-click creates a selection, this clears it. unfortunately that leads to a
555+
// flicker, but its unavoidable without introducing a lag
548556
}
549557
}
550558
}

0 commit comments

Comments
 (0)