diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp index 754bc897..e028dee8 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.cpp @@ -760,14 +760,15 @@ void MidiKeyboardComponent::mouseDrag (const MouseEvent& e) float mousePositionVelocity; auto newNote = xyToNote (e.position, mousePositionVelocity); - if (newNote >= 0) - mouseDraggedToKey (newNote, e); - - updateNoteUnderMouse (e, true); + if (newNote >= 0) + { + if (mouseDraggedToKey (newNote, e)) + updateNoteUnderMouse (e, true); + } } bool MidiKeyboardComponent::mouseDownOnKey (int, const MouseEvent&) { return true; } -void MidiKeyboardComponent::mouseDraggedToKey (int, const MouseEvent&) {} +bool MidiKeyboardComponent::mouseDraggedToKey (int, const MouseEvent&) { return true; } void MidiKeyboardComponent::mouseUpOnKey (int, const MouseEvent&) {} void MidiKeyboardComponent::mouseDown (const MouseEvent& e) diff --git a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h index f08610af..86428224 100644 --- a/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h +++ b/modules/juce_audio_utils/gui/juce_MidiKeyboardComponent.h @@ -369,10 +369,14 @@ protected: */ virtual bool mouseDownOnKey (int midiNoteNumber, const MouseEvent& e); - /** Callback when the mouse is dragged from one key onto another. + /** Callback when the mouse is dragged from one key onto another. + + Return true if you want the drag to trigger the note, or false if you + want to handle it yourself and not have the note played. + @see mouseDownOnKey */ - virtual void mouseDraggedToKey (int midiNoteNumber, const MouseEvent& e); + virtual bool mouseDraggedToKey (int midiNoteNumber, const MouseEvent& e); /** Callback when the mouse is released from a key. @see mouseDownOnKey