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