Propagate keyboard event accept status
authorMorten Johan Sørvig <morten.sorvig@digia.com>
Sat, 22 Nov 2014 14:11:36 +0000 (15:11 +0100)
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Thu, 13 Aug 2015 18:33:39 +0000 (18:33 +0000)
Set the accepted bit on the QWindowsystemInterface
keyboard event after processing the key event.

Change-Id: I2d8c9382f14840e464153870dff909000e64ddcd
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
src/gui/kernel/qguiapplication.cpp
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface.h

index f240153f9f0bdecbcd18f9d3ae39d29670ff83b7..5e2a5b86a4003b932df5b6fded710d674e1a725b 100644 (file)
@@ -1935,6 +1935,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
         }
     }
 #endif
+    e->eventAccepted = ev.isAccepted();
 }
 
 void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
index 8c429150a8590f90bd2d8f7d2cb7ec732384977a..7db38b5909d4ec0b764b939145464dd835f475b1 100644 (file)
@@ -303,24 +303,24 @@ bool QWindowSystemInterface::tryHandleExtendedShortcutEvent(QWindow *w, ulong ti
 }
 
 
-void QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
+bool QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
     unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
-    handleKeyEvent(w, time, t, k, mods, text, autorep, count);
+    return handleKeyEvent(w, time, t, k, mods, text, autorep, count);
 }
 
-void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
+bool QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
 {
     // This is special handling needed for OS X which eventually will call sendEvent(), on other platforms
     // this might not be safe, e.g., on Android. See: QGuiApplicationPrivate::processKeyEvent() for
     // shortcut overriding on other platforms.
 #if defined(Q_OS_OSX)
     if (t == QEvent::KeyPress && QWindowSystemInterface::tryHandleShortcutEvent(tlw, timestamp, k, mods, text))
-        return;
+        return true;
 #endif // Q_OS_OSX
 
     QWindowSystemInterfacePrivate::KeyEvent * e =
             new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
-    QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+    return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
 }
 
 void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
index 453dbe81cfabc1b8a0addad93ba6fa04096a5dc2..ace1a4fe244c86efb5f048ae5f78fac4423b6a36 100644 (file)
@@ -95,8 +95,8 @@ public:
                                                           quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
                                                           const QString & text = QString(), bool autorep = false, ushort count = 1);
 
-    static void handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
-    static void handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+    static bool handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+    static bool handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
 
     static void handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
                                        quint32 nativeScanCode, quint32 nativeVirtualKey,