diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-15 06:19:31 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-15 06:19:31 (GMT) |
commit | d333d8a813460ae884e3d6a2d2def290cd5fea39 (patch) | |
tree | a8f2978f9c4c45bfe3735af6be58aeb94cbdb9fb /src/declarative/fx/qfxkeyproxy.cpp | |
parent | 11ec67108d56dc29631ddbd90be840021d83f6c1 (diff) | |
download | Qt-d333d8a813460ae884e3d6a2d2def290cd5fea39.zip Qt-d333d8a813460ae884e3d6a2d2def290cd5fea39.tar.gz Qt-d333d8a813460ae884e3d6a2d2def290cd5fea39.tar.bz2 |
Support input method proxying in KeyProxy. KeyProxy cleanup.
Diffstat (limited to 'src/declarative/fx/qfxkeyproxy.cpp')
-rw-r--r-- | src/declarative/fx/qfxkeyproxy.cpp | 62 |
1 files changed, 48 insertions, 14 deletions
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; } } |