mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Fixed an issue overriding MidiKeyboardComponent::mouseDownOnKey
This commit is contained in:
parent
f58eacc135
commit
1e021b6ed0
2 changed files with 9 additions and 19 deletions
|
|
@ -752,7 +752,6 @@ void MidiKeyboardComponent::updateNoteUnderMouse (Point<float> pos, bool isDown,
|
|||
void MidiKeyboardComponent::mouseMove (const MouseEvent& e)
|
||||
{
|
||||
updateNoteUnderMouse (e, false);
|
||||
shouldCheckMousePos = false;
|
||||
}
|
||||
|
||||
void MidiKeyboardComponent::mouseDrag (const MouseEvent& e)
|
||||
|
|
@ -760,14 +759,12 @@ 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 && 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)
|
||||
|
|
@ -776,16 +773,12 @@ void MidiKeyboardComponent::mouseDown (const MouseEvent& e)
|
|||
auto newNote = xyToNote (e.position, mousePositionVelocity);
|
||||
|
||||
if (newNote >= 0 && mouseDownOnKey (newNote, e))
|
||||
{
|
||||
updateNoteUnderMouse (e, true);
|
||||
shouldCheckMousePos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MidiKeyboardComponent::mouseUp (const MouseEvent& e)
|
||||
{
|
||||
updateNoteUnderMouse (e, false);
|
||||
shouldCheckMousePos = false;
|
||||
|
||||
float mousePositionVelocity;
|
||||
auto note = xyToNote (e.position, mousePositionVelocity);
|
||||
|
|
@ -830,13 +823,6 @@ void MidiKeyboardComponent::timerCallback()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldCheckMousePos)
|
||||
{
|
||||
for (auto& ms : Desktop::getInstance().getMouseSources())
|
||||
if (ms.getComponentUnderMouse() == this || isParentOf (ms.getComponentUnderMouse()))
|
||||
updateNoteUnderMouse (getLocalPoint (nullptr, ms.getScreenPosition()), ms.isDragging(), ms.getIndex());
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -370,9 +370,13 @@ protected:
|
|||
virtual bool mouseDownOnKey (int midiNoteNumber, const MouseEvent& e);
|
||||
|
||||
/** Callback when the mouse is dragged from one key onto another.
|
||||
|
||||
Return true if you want the drag to trigger the new 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
|
||||
|
|
@ -414,7 +418,7 @@ private:
|
|||
|
||||
int rangeStart = 0, rangeEnd = 127;
|
||||
float firstKey = 12 * 4.0f;
|
||||
bool canScroll = true, useMousePositionForVelocity = true, shouldCheckMousePos = false;
|
||||
bool canScroll = true, useMousePositionForVelocity = true;
|
||||
std::unique_ptr<Button> scrollDown, scrollUp;
|
||||
|
||||
Array<KeyPress> keyPresses;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue