Skip to content

Commit

Permalink
Select piano key from mouse position
Browse files Browse the repository at this point in the history
When selecting a Piano Key to mark semi tones 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.
  • Loading branch information
zonkmachine committed May 2, 2020
1 parent 687870d commit bd4bcdc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/PianoRoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ protected slots:

QList<int> m_markedSemiTones;
QMenu * m_semiToneMarkerMenu; // when you right click on the key area
int m_pianoKeySelected;

PianoRoll();
PianoRoll( const PianoRoll & );
Expand Down
3 changes: 2 additions & 1 deletion src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SemiToneMarkerAction>( i ) )
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd4bcdc

Please sign in to comment.