From 0ddfe26ffbf2d4aa8f9ae7f3b4bc6661b03da1b3 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Thu, 8 Sep 2011 03:11:33 +0200 Subject: [PATCH] Fix selection behavior --- Sources/VLSheetView.h | 1 + Sources/VLSheetViewSelection.mm | 26 +++++++++----------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Sources/VLSheetView.h b/Sources/VLSheetView.h index 0da0174..f87c9dc 100644 --- a/Sources/VLSheetView.h +++ b/Sources/VLSheetView.h @@ -88,6 +88,7 @@ enum VLCursorVisual { size_t fCursorStanza; int fSelStart; int fSelEnd; + int fSelAnchor; int fNumTopLedgers; int fNumBotLedgers; int fNumStanzas; diff --git a/Sources/VLSheetViewSelection.mm b/Sources/VLSheetViewSelection.mm index 32407ab..943a1fe 100644 --- a/Sources/VLSheetViewSelection.mm +++ b/Sources/VLSheetViewSelection.mm @@ -111,47 +111,39 @@ VLSequenceCallback( - (void)editSelection { - fSelStart = fSelEnd = fCursorMeasure; + fSelStart = fSelEnd = fSelAnchor = fCursorMeasure; [self updateMenus]; [self setNeedsDisplay:YES]; } - (void)adjustSelection:(NSEvent *)event { - int prevMeasure = fCursorMeasure; switch ([self findRegionForEvent:event]) { case kRegionNote: case kRegionChord: case kRegionLyrics: - if (fCursorAt.fNum) - ++fCursorMeasure; + if (fCursorAt.fNum > 0 && fCursorMeasure >= fSelAnchor) + ++fCursorMeasure; // // Fall through // case kRegionMeasure: fCursorMeasure = std::max(0, std::min(fCursorMeasure, [self song]->CountMeasures())); - if (fCursorMeasure > fSelEnd) { + if (fCursorMeasure >= fSelAnchor) { + fSelStart = fSelAnchor; fSelEnd = fCursorMeasure; [self updateMenus]; [self setNeedsDisplay:YES]; - } else if (fCursorMeasure < fSelStart) { - fSelStart = fCursorMeasure; - [self updateMenus]; - [self setNeedsDisplay:YES]; - } else if (prevMeasure == fSelEnd && fCursorMeasureprevMeasure) { + } else { fSelStart = fCursorMeasure; + fSelEnd = fSelAnchor; [self updateMenus]; [self setNeedsDisplay:YES]; } break; - default: - fCursorMeasure = prevMeasure; - break; + default: + break; } fCursorRegion = kRegionMeasure; }