summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/fx/qfxitem.h6
-rw-r--r--src/declarative/fx/qfxkeyproxy.cpp18
-rw-r--r--tools/qmlviewer/qmlviewer.cpp1
3 files changed, 22 insertions, 3 deletions
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 8c8bcc4..9df3c18 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -296,6 +296,10 @@ Q_SIGNALS:
void qmlChanged();
void newChildCreated(const QString &url, QScriptValue);
+public: //### for KeyProxy
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+
protected:
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
virtual void childrenChanged();
@@ -312,8 +316,6 @@ protected:
virtual void parentChanged(QFxItem *, QFxItem *);
virtual void focusChanged(bool);
virtual void activeFocusChanged(bool);
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
virtual void geometryChanged(const QRectF &newGeometry,
const QRectF &oldGeometry);
diff --git a/src/declarative/fx/qfxkeyproxy.cpp b/src/declarative/fx/qfxkeyproxy.cpp
index e76a9b7..62f468c 100644
--- a/src/declarative/fx/qfxkeyproxy.cpp
+++ b/src/declarative/fx/qfxkeyproxy.cpp
@@ -40,9 +40,11 @@
****************************************************************************/
#include "qfxkeyproxy.h"
-
+#include <QGraphicsScene>
+#include <QKeyEvent>
QT_BEGIN_NAMESPACE
+
QML_DEFINE_TYPE(QFxKeyProxy,KeyProxy)
/*!
@@ -94,11 +96,25 @@ QList<QFxItem *> *QFxKeyProxy::targets() const
void QFxKeyProxy::keyPressEvent(QKeyEvent *e)
{
// ### GV
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = d->targets.at(ii); //scene()->focusItem()
+ if (i)
+ i->keyPressEvent(e);
+ if (e->isAccepted())
+ return;
+ }
}
void QFxKeyProxy::keyReleaseEvent(QKeyEvent *e)
{
// ### GV
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = d->targets.at(ii); //scene()->focusItem()
+ if (i)
+ i->keyReleaseEvent(e);
+ if (e->isAccepted())
+ return;
+ }
}
QT_END_NAMESPACE
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 548434a..cdabd86 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -142,6 +142,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
canvas->setAttribute(Qt::WA_OpaquePaintEvent);
canvas->setAttribute(Qt::WA_NoSystemBackground);
canvas->setContentResizable(!skin || !scaleSkin);
+ canvas->setFocus();
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));