From b8e4c614f3f6ee2435d1c412da18cf7ca82c2120 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Thu, 8 Sep 2011 03:19:41 +0200 Subject: [PATCH] Extend selection with shift-click --- Sources/VLSheetView.mm | 2 +- Sources/VLSheetViewSelection.h | 4 ++-- Sources/VLSheetViewSelection.mm | 13 ++++++++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Sources/VLSheetView.mm b/Sources/VLSheetView.mm index 465d492..8be5b33 100644 --- a/Sources/VLSheetView.mm +++ b/Sources/VLSheetView.mm @@ -850,7 +850,7 @@ const float kSemiFloor = -1.0f*kLineH; [self editLyrics]; break; case kRegionMeasure: - [self editSelection]; + [self editSelection:([event modifierFlags] & NSShiftKeyMask) != 0]; break; default: break; diff --git a/Sources/VLSheetViewSelection.h b/Sources/VLSheetViewSelection.h index d606202..61be7ba 100644 --- a/Sources/VLSheetViewSelection.h +++ b/Sources/VLSheetViewSelection.h @@ -5,14 +5,14 @@ // // (MN) Matthias Neeracher // -// Copyright © 2006-2007 Matthias Neeracher +// Copyright © 2006-2011 Matthias Neeracher // #import "VLMIDIWriter.h" @interface VLSheetView (Selection) -- (void)editSelection; +- (void)editSelection:(BOOL)extend; - (void)adjustSelection:(NSEvent *)event; - (NSRange)sectionsInSelection; diff --git a/Sources/VLSheetViewSelection.mm b/Sources/VLSheetViewSelection.mm index 943a1fe..0443e33 100644 --- a/Sources/VLSheetViewSelection.mm +++ b/Sources/VLSheetViewSelection.mm @@ -5,7 +5,7 @@ // // (MN) Matthias Neeracher // -// Copyright © 2006-2007 Matthias Neeracher +// Copyright © 2006-2011 Matthias Neeracher // #import "VLSheetView.h" @@ -109,9 +109,16 @@ VLSequenceCallback( @implementation VLSheetView (Selection) -- (void)editSelection +- (void)editSelection:(BOOL)extend { - fSelStart = fSelEnd = fSelAnchor = fCursorMeasure; + if (extend && fSelStart > -1) { + if (fCursorMeasure > fSelEnd) + fSelEnd = fCursorMeasure; + else if (fCursorMeasure < fSelStart) + fSelStart = fCursorMeasure; + } else { + fSelStart = fSelEnd = fSelAnchor = fCursorMeasure; + } [self updateMenus]; [self setNeedsDisplay:YES]; }