Skip to content

Commit

Permalink
BugFix (#139) When right clicking during a ScribbleForEvent/MouseDrag…
Browse files Browse the repository at this point in the history
…Action, and the right click is outside the plot, the last scribble event was not being generated.
  • Loading branch information
Snolandia authored Oct 16, 2024
1 parent 2e0d0d7 commit fd8ea3a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions lib/jkqtplotter/jkqtplotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,7 @@ void JKQTPlotter::mouseMoveEvent ( QMouseEvent * event ) {


void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){
MouseDragAction prevAction = currentMouseDragAction;
currentMouseDragAction.clear();
mouseDragMarkers.clear();

Expand All @@ -906,11 +907,18 @@ void JKQTPlotter::mousePressEvent ( QMouseEvent * event ){
oldImage=image;
if (currentMouseDragAction.mode==jkqtpmdaScribbleForEvents) emit userScribbleClick(mouseDragRectXStart, mouseDragRectYStart, event->modifiers(), true, false);
event->accept();
} else if (event->button()==Qt::RightButton && event->modifiers()==Qt::NoModifier && contextMenuMode!=jkqtpcmmNoContextMenu) {
mouseLastClickX=event->pos().x();
mouseLastClickY=event->pos().y();
openContextMenu(event->pos().x(), event->pos().y());
event->accept();
} else if (event->button()==Qt::RightButton) {
if (prevAction.mode==jkqtpmdaScribbleForEvents){
mouseDragRectXStart=plotter->p2x(event->pos().x()/magnification);
mouseDragRectYStart=plotter->p2y((event->pos().y()-getPlotYOffset())/magnification);
emit userScribbleClick(mouseDragRectXStart, mouseDragRectYStart, event->modifiers(), false, true);
}
if(event->modifiers()==Qt::NoModifier && contextMenuMode!=jkqtpcmmNoContextMenu){
mouseLastClickX=event->pos().x();
mouseLastClickY=event->pos().y();
openContextMenu(event->pos().x(), event->pos().y());
event->accept();
}
}

// emit clicked signal, if event occured inside plot only
Expand Down

0 comments on commit fd8ea3a

Please sign in to comment.