Refactor fix for keyboard crash

This commit is contained in:
Gabriel Calero 2018-03-14 19:18:42 -03:00
parent e744edc6a0
commit d0f1aa9020

View file

@ -181,28 +181,20 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event)
}
break;
}
case QEvent::InputMethod: {
auto window = getWindow();
if (window && window->activeFocusItem()) {
event->ignore();
if (QCoreApplication::sendEvent(window->activeFocusItem(), event)) {
return event->isAccepted();
}
return false;
}
break;
}
case QEvent::InputMethod:
case QEvent::InputMethodQuery: {
auto window = getWindow();
if (window && window->activeFocusItem()) {
event->ignore();
if (QCoreApplication::sendEvent(window->activeFocusItem(), event)) {
bool eventAccepted = event->isAccepted();
QInputMethodQueryEvent* imqEvent = static_cast<QInputMethodQueryEvent*>(event);
// this block disables the selection cursor in android which appears in
// the top-left corner of the screen
if (imqEvent->queries() & Qt::ImEnabled) {
imqEvent->setValue(Qt::ImEnabled, QVariant(false));
if (event->type() == QEvent::InputMethodQuery) {
QInputMethodQueryEvent *imqEvent = static_cast<QInputMethodQueryEvent *>(event);
// this block disables the selection cursor in android which appears in
// the top-left corner of the screen
if (imqEvent->queries() & Qt::ImEnabled) {
imqEvent->setValue(Qt::ImEnabled, QVariant(false));
}
}
return eventAccepted;
}