Maliit: Fix enter on VKB not resulting in text input field acceptance
Pressing enter on the VKB should result in the emission of the accepted() for text input fields in QML or the returnPressed() signal in QLineEdit. In that case the Maliit input server calls our keyEvent method over DBus, which this patch implements. Change-Id: I46170c30315adaf21db0e232f53780ccaa67e4bf Reviewed-by: Jan Arne Petersen <jpetersen@openismus.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@nokia.com>
This commit is contained in:
parent
b27bf9bb94
commit
fe7265a0bb
@ -127,6 +127,13 @@ static TextContentType contentTypeFromHints(Qt::InputMethodHints hints)
|
||||
return type;
|
||||
}
|
||||
|
||||
/// From Maliit's namespace.h
|
||||
enum MaliitEventRequestType {
|
||||
EventRequestBoth, //!< Both a Qt::KeyEvent and a signal
|
||||
EventRequestSignalOnly, //!< Only a signal
|
||||
EventRequestEventOnly //!< Only a Qt::KeyEvent
|
||||
};
|
||||
|
||||
static QString maliitServerAddress()
|
||||
{
|
||||
org::maliit::Server::Address serverAddress(QStringLiteral("org.maliit.server"), QStringLiteral("/org/maliit/server/address"), QDBusConnection::sessionBus());
|
||||
@ -383,9 +390,27 @@ void QMaliitPlatformInputContext::imInitiatedHide()
|
||||
// ### clear focus
|
||||
}
|
||||
|
||||
void QMaliitPlatformInputContext::keyEvent(int, int, int, const QString &, bool, int, uchar)
|
||||
void QMaliitPlatformInputContext::keyEvent(int type, int key, int modifiers, const QString &text,
|
||||
bool autoRepeat, int count, uchar requestType_)
|
||||
{
|
||||
// Not supported at the moment.
|
||||
MaliitEventRequestType requestType = MaliitEventRequestType(requestType_);
|
||||
if (requestType == EventRequestSignalOnly) {
|
||||
qWarning() << "Maliit: Signal emitted key events are not supported.";
|
||||
return;
|
||||
}
|
||||
|
||||
// HACK: This code relies on QEvent::Type for key events and modifiers to be binary compatible between
|
||||
// Qt 4 and 5.
|
||||
QEvent::Type eventType = static_cast<QEvent::Type>(type);
|
||||
if (type != QEvent::KeyPress && type != QEvent::KeyRelease) {
|
||||
qWarning() << "Maliit: Unknown key event type" << type;
|
||||
return;
|
||||
}
|
||||
|
||||
QKeyEvent event(eventType, key, static_cast<Qt::KeyboardModifiers>(modifiers),
|
||||
text, autoRepeat, count);
|
||||
if (d->window)
|
||||
QCoreApplication::sendEvent(d->window.data(), &event);
|
||||
}
|
||||
|
||||
void QMaliitPlatformInputContext::paste()
|
||||
|
@ -76,7 +76,7 @@ public Q_SLOTS:
|
||||
void updatePreedit(const QDBusMessage &message);
|
||||
void copy();
|
||||
void imInitiatedHide();
|
||||
void keyEvent(int , int , int , const QString &, bool , int , uchar );
|
||||
void keyEvent(int type, int key, int modifiers, const QString &text, bool autoRepeat, int count, uchar requestType_);
|
||||
void paste();
|
||||
bool preeditRectangle(int &x, int &y, int &width, int &height);
|
||||
bool selection(QString &selection);
|
||||
|
Loading…
Reference in New Issue
Block a user