Cocoa: Don't let key events triggering input method events close dialog.
Added a flag to QCocoaWindow to ignore shouldCloseWindow. This is set from within QNSView when escape is pressed and the current focus widgets is processing input method events (like QTextEdit). This lead to unwanted dialog rejects. Task-number: QTBUG-44076 Change-Id: Ic90a8a6ba8c5cddbc0d486563acad57dd384d179 Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
parent
aa2c5ba995
commit
e6b97fd2c7
@ -265,6 +265,7 @@ public: // for QNSView
|
||||
QPointer<QWindow> m_enterLeaveTargetWindow;
|
||||
bool m_windowUnderMouse;
|
||||
|
||||
bool m_ignoreWindowShouldClose;
|
||||
bool m_inConstructor;
|
||||
bool m_inSetVisible;
|
||||
bool m_inSetGeometry;
|
||||
|
@ -371,6 +371,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
||||
, m_synchedWindowState(Qt::WindowActive)
|
||||
, m_windowModality(Qt::NonModal)
|
||||
, m_windowUnderMouse(false)
|
||||
, m_ignoreWindowShouldClose(false)
|
||||
, m_inConstructor(true)
|
||||
, m_inSetVisible(false)
|
||||
, m_inSetGeometry(false)
|
||||
@ -1218,6 +1219,9 @@ void QCocoaWindow::windowDidEndLiveResize()
|
||||
|
||||
bool QCocoaWindow::windowShouldClose()
|
||||
{
|
||||
// might have been set from qnsview.mm
|
||||
if (m_ignoreWindowShouldClose)
|
||||
return false;
|
||||
bool accepted = false;
|
||||
QWindowSystemInterface::handleCloseEvent(window(), &accepted);
|
||||
QWindowSystemInterface::flushWindowSystemEvents();
|
||||
|
@ -1437,6 +1437,10 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
||||
|
||||
QObject *fo = QGuiApplication::focusObject();
|
||||
if (m_sendKeyEvent && fo) {
|
||||
// if escape is pressed we don't want interpretKeyEvents to close a dialog. This will be done via QWindowSystemInterface
|
||||
if (keyCode == Qt::Key_Escape)
|
||||
m_platformWindow->m_ignoreWindowShouldClose = true;
|
||||
|
||||
QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImHints);
|
||||
if (QCoreApplication::sendEvent(fo, &queryEvent)) {
|
||||
bool imEnabled = queryEvent.value(Qt::ImEnabled).toBool();
|
||||
@ -1446,6 +1450,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
||||
[self interpretKeyEvents:[NSArray arrayWithObject:nsevent]];
|
||||
}
|
||||
}
|
||||
|
||||
m_platformWindow->m_ignoreWindowShouldClose = false;;
|
||||
}
|
||||
if (m_resendKeyEvent)
|
||||
m_sendKeyEvent = true;
|
||||
|
Loading…
Reference in New Issue
Block a user