summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/fx/qfxitem.h6
-rw-r--r--src/declarative/fx/qfxkeyproxy.cpp62
-rw-r--r--src/declarative/fx/qfxkeyproxy.h1
3 files changed, 51 insertions, 18 deletions
diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h
index 9095864..55cb693 100644
--- a/src/declarative/fx/qfxitem.h
+++ b/src/declarative/fx/qfxitem.h
@@ -296,10 +296,6 @@ 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();
@@ -316,6 +312,8 @@ protected:
virtual void parentChanged(QFxItem *, QFxItem *);
virtual void focusChanged(bool);
virtual void activeFocusChanged(bool);
+ virtual void keyPressEvent(QKeyEvent *event);
+ virtual 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 62f468c..f07691a 100644
--- a/src/declarative/fx/qfxkeyproxy.cpp
+++ b/src/declarative/fx/qfxkeyproxy.cpp
@@ -64,12 +64,19 @@ QML_DEFINE_TYPE(QFxKeyProxy,KeyProxy)
class QFxKeyProxyPrivate
{
public:
+ QFxKeyProxyPrivate() : inPress(false), inRelease(false), inIM(false) {}
QList<QFxItem *> targets;
+
+ //loop detection
+ bool inPress:1;
+ bool inRelease:1;
+ bool inIM:1;
};
QFxKeyProxy::QFxKeyProxy(QFxItem *parent)
: QFxItem(parent), d(new QFxKeyProxyPrivate)
{
+ setOptions(AcceptsInputMethods);
}
QFxKeyProxy::~QFxKeyProxy()
@@ -95,25 +102,52 @@ 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;
+ if (!d->inPress) {
+ d->inPress = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = d->targets.at(ii); //### FocusRealm
+ if (i && scene())
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inPress = false;
+ return;
+ }
+ }
+ d->inPress = false;
}
}
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;
+ if (!d->inRelease) {
+ d->inRelease = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = d->targets.at(ii); //### FocusRealm
+ if (i && scene())
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inRelease = false;
+ return;
+ }
+ }
+ d->inRelease = false;
+ }
+}
+
+void QFxKeyProxy::inputMethodEvent(QInputMethodEvent *e)
+{
+ if (!d->inIM) {
+ d->inIM = true;
+ for (int ii = 0; ii < d->targets.count(); ++ii) {
+ QFxItem *i = d->targets.at(ii); //### FocusRealm
+ if (i && scene())
+ scene()->sendEvent(i, e);
+ if (e->isAccepted()) {
+ d->inIM = false;
+ return;
+ }
+ }
+ d->inIM = false;
}
}
diff --git a/src/declarative/fx/qfxkeyproxy.h b/src/declarative/fx/qfxkeyproxy.h
index d075295..8bcdc26 100644
--- a/src/declarative/fx/qfxkeyproxy.h
+++ b/src/declarative/fx/qfxkeyproxy.h
@@ -64,6 +64,7 @@ public:
protected:
virtual void keyPressEvent(QKeyEvent *);
virtual void keyReleaseEvent(QKeyEvent *);
+ virtual void inputMethodEvent(QInputMethodEvent *);
private:
Q_DISABLE_COPY(QFxKeyProxy)