Commit b71b9efd authored by Clinton Stimpson's avatar Clinton Stimpson

ENH: Add support for "editing" line edits and spin boxes.

parent 6961b47b
......@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QApplication>
#include <QContextMenuEvent>
#include <QKeyEvent>
#include <QWidget>
#include <QtDebug>
......@@ -43,7 +44,7 @@ pqBasicWidgetEventPlayer::pqBasicWidgetEventPlayer(QObject* p)
}
bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
const QString& Command, const QString& /*Arguments*/,
const QString& Command, const QString& Arguments,
bool& /*Error*/)
{
QWidget* widget = qobject_cast<QWidget*>(Object);
......@@ -57,6 +58,14 @@ bool pqBasicWidgetEventPlayer::playEvent(QObject* Object,
QCoreApplication::sendEvent(widget, &e);
return true;
}
else if(Command == "key")
{
QKeyEvent kd(QEvent::KeyPress, Arguments.toInt(), Qt::NoModifier);
QKeyEvent ku(QEvent::KeyRelease, Arguments.toInt(), Qt::NoModifier);
QCoreApplication::sendEvent(widget, &kd);
QCoreApplication::sendEvent(widget, &ku);
return true;
}
else
{
return false;
......
......@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <QSpinBox>
#include <QTextDocument>
#include <QTextEdit>
#include <QKeyEvent>
pqLineEditEventTranslator::pqLineEditEventTranslator(QObject* p)
: pqWidgetEventTranslator(p)
......@@ -62,13 +63,22 @@ bool pqLineEditEventTranslator::translateEvent(QObject* Object, QEvent* Event, b
{
case QEvent::KeyRelease:
{
if (object)
QKeyEvent* ke = static_cast<QKeyEvent*>(Event);
QString keyText = ke->text();
if(keyText.length() && keyText.at(0).isLetterOrNumber())
{
emit recordEvent(Object, "set_string", object->text());
if (object)
{
emit recordEvent(Object, "set_string", object->text());
}
else if (teObject)
{
emit recordEvent(Object, "set_string", teObject->document()->toPlainText());
}
}
else if (teObject)
else
{
emit recordEvent(Object, "set_string", teObject->document()->toPlainText());
emit recordEvent(Object, "key", QString("%1").arg(ke->key()));
}
}
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment