diff --git a/src/musrgui/PGetFunctionsBlockDialog.cpp b/src/musrgui/PGetFunctionsBlockDialog.cpp index eec756d1..d3357aab 100644 --- a/src/musrgui/PGetFunctionsBlockDialog.cpp +++ b/src/musrgui/PGetFunctionsBlockDialog.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "PGetFunctionsBlockDialog.h" diff --git a/src/musrgui/PGetPlotDialog.cpp b/src/musrgui/PGetPlotDialog.cpp index c17e7d04..99fbc8e9 100644 --- a/src/musrgui/PGetPlotDialog.cpp +++ b/src/musrgui/PGetPlotDialog.cpp @@ -44,6 +44,9 @@ */ PGetPlotDialog::PGetPlotDialog() { + // setup event filter + installEventFilter(this); + fXRangeLow_lineEdit->setValidator( new QDoubleValidator(fXRangeLow_lineEdit) ); fXRangeUp_lineEdit->setValidator( new QDoubleValidator(fXRangeUp_lineEdit) ); fYRangeLow_lineEdit->setValidator( new QDoubleValidator(fYRangeLow_lineEdit) ); @@ -144,6 +147,29 @@ void PGetPlotDialog::addPlot() fRunList_lineEdit->setFocus(); } +//---------------------------------------------------------------------------------------------------- +/** + *

This event filter is filtering out the return key, and if present adds the current plot. + */ +bool PGetPlotDialog::eventFilter( QObject *obj, QEvent *ev ) +{ + if (obj == this) { + if (ev->type() == QEvent::KeyPress) { + QKeyEvent *k = (QKeyEvent*)ev; + if (k->key() == Qt::Key_Return) { + addPlot(); + return true; + } else { + return false; + } + } else { + return false; + } + } else { + return false; + } +} + //---------------------------------------------------------------------------------------------------- // END //---------------------------------------------------------------------------------------------------- diff --git a/src/musrgui/PGetPlotDialog.h b/src/musrgui/PGetPlotDialog.h index 5a1f27d9..222d99aa 100644 --- a/src/musrgui/PGetPlotDialog.h +++ b/src/musrgui/PGetPlotDialog.h @@ -43,6 +43,9 @@ class PGetPlotDialog : public PGetPlotDialogBase public slots: void addPlot(); + + protected: + bool eventFilter( QObject *obj, QEvent *ev ); }; #endif // _PGETPLOTDIALOG_H_ diff --git a/src/musrgui/forms/PGetFunctionsBlockDialogBase.ui b/src/musrgui/forms/PGetFunctionsBlockDialogBase.ui index 83e47588..046d77d7 100644 --- a/src/musrgui/forms/PGetFunctionsBlockDialogBase.ui +++ b/src/musrgui/forms/PGetFunctionsBlockDialogBase.ui @@ -240,7 +240,7 @@ FUNCTIONS buttonOk - clicked() + released() PGetFunctionsBlockDialogBase accept() diff --git a/src/musrgui/forms/PGetPlotDialogBase.ui b/src/musrgui/forms/PGetPlotDialogBase.ui index a9dda97e..ff8ebc6c 100644 --- a/src/musrgui/forms/PGetPlotDialogBase.ui +++ b/src/musrgui/forms/PGetPlotDialogBase.ui @@ -314,7 +314,7 @@ fOk_button - clicked() + released() PGetPlotDialogBase accept()