diff --git a/jkqtplotter.cpp b/jkqtplotter.cpp index dc0542650c..272c63e854 100644 --- a/jkqtplotter.cpp +++ b/jkqtplotter.cpp @@ -60,6 +60,8 @@ JKQtPlotter::JKQtPlotter(QWidget *parent): void JKQtPlotter::init(bool datastore_internal, QWidget* parent, JKQTPdatastore* datast) { + mouseContextX=0; + mouseContextY=0; setParent(parent); connect(&resizeTimer, SIGNAL(timeout()), this, SLOT(delayedResizeEvent())); doDrawing=false; @@ -303,9 +305,12 @@ void JKQtPlotter::mousePressEvent ( QMouseEvent * event ){ //update(); event->accept(); } else if (rightMouseButtonAction==JKQtPlotter::RightMouseButtonContextMenu) { + mouseContextX=plotter->p2x(event->x()/magnification); + mouseContextY=plotter->p2y((event->y()-getPlotYOffset())/magnification); contextMenu->close(); initContextMenu(); contextMenu->popup(event->globalPos()); + emit contextMenuOpened(mouseContextX, mouseContextY, contextMenu); event->accept(); } } diff --git a/jkqtplotter.h b/jkqtplotter.h index 7828d49e20..66a7763dc2 100644 --- a/jkqtplotter.h +++ b/jkqtplotter.h @@ -202,6 +202,9 @@ class LIB_EXPORT JKQtPlotter: public QWidget { JKQTPGET_SET_MACRO(bool, zoomByMouseWheel); + JKQTPGetMacro(double, mouseContextX) + JKQTPGetMacro(double, mouseContextY) + inline JKQTPhorizontalAxis* getXAxis() { return plotter->getXAxis(); } inline JKQTPverticalAxis* getYAxis() { return plotter->getYAxis(); } inline JKQTPhorizontalAxis* get_xAxis() { return plotter->get_xAxis(); } @@ -410,6 +413,8 @@ class LIB_EXPORT JKQtPlotter: public QWidget { void plotScalingRecalculated(); /** \brief emitted before the plot scaling has been recalculated */ void beforePlotScalingRecalculate(); + /** \brief emitted when a context-emnu was opened at the given position */ + void contextMenuOpened(double x, double y, QMenu* contextMenu); /** \brief signal: emitted whenever the user selects a new x-y zoom range (by mouse) */ @@ -590,6 +595,8 @@ class LIB_EXPORT JKQtPlotter: public QWidget { QSize minSize; QMenu* contextMenu; + double mouseContextX; + double mouseContextY; QList contextSubMenus; void initContextMenu();