From ca09b2908754d9e41d3d2d9efcc34cb9051cf9bd Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Sat, 2 May 2020 09:41:44 +0200 Subject: [PATCH] Select the correct piano key for marking semitones (#5478) When selecting a Piano Key to mark semitones in the Piano Roll we select key from the y position of the pop-up menu and not the mouse. Incidentally these two are most often the same as the menu builds from the mouse y positon and down. If there is room for it. If there is no room downward it will create the menu so the lower part of the frame aligns with the mouse y position. Fixed by creating a variable to hold the pressed key before creating the menu. --- include/PianoRoll.h | 1 + src/gui/editors/PianoRoll.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 9167804ae..125ed56d9 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -250,6 +250,7 @@ private: QList m_markedSemiTones; QMenu * m_semiToneMarkerMenu; // when you right click on the key area + int m_pianoKeySelected; PianoRoll(); PianoRoll( const PianoRoll & ); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index d6dec21ee..358be5ab5 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -507,7 +507,7 @@ void PianoRoll::changeNoteEditMode( int i ) void PianoRoll::markSemiTone( int i ) { - const int key = getKey( mapFromGlobal( m_semiToneMarkerMenu->pos() ).y() ); + const int key = m_pianoKeySelected; const InstrumentFunctionNoteStacking::Chord * chord = nullptr; switch( static_cast( i ) ) @@ -1704,6 +1704,7 @@ void PianoRoll::mousePressEvent(QMouseEvent * me ) if( me->buttons() == Qt::RightButton ) { // right click, tone marker contextual menu + m_pianoKeySelected = getKey( me->y() ); m_semiToneMarkerMenu->popup( mapToGlobal( QPoint( me->x(), me->y() ) ) ); } else