summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2018-04-16 13:40:53 -0700
committerGabriel de Dietrich <gabriel.dedietrich@qt.io>2018-04-18 17:22:40 +0000
commit84988886a5503e236ac2eb839cf62a01d8a4789b (patch)
tree70ebe72f7423afef96265600fdbffc8764d6753f /src/widgets
parent0c936d74118a31dcee777a3a4a8938590e79c334 (diff)
QToolTip: Hide tooltip on key event on macOS
This brings back Qt 4 behavior. The difference is that we only ignore modifier-only key events, as it's done natively. Task-number: QTBUG-49462 Change-Id: I02f2313e1164ba185336d80ac5cc16ce6d883b79 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qtooltip.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index baf717d715..ed7184302a 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -317,15 +317,13 @@ void QTipLabel::timerEvent(QTimerEvent *e)
bool QTipLabel::eventFilter(QObject *o, QEvent *e)
{
switch (e->type()) {
-#if 0 // Used to be included in Qt4 for Q_WS_MAC
+#ifdef Q_OS_MACOS
case QEvent::KeyPress:
case QEvent::KeyRelease: {
- int key = static_cast<QKeyEvent *>(e)->key();
- Qt::KeyboardModifiers mody = static_cast<QKeyEvent *>(e)->modifiers();
- if (!(mody & Qt::KeyboardModifierMask)
- && key != Qt::Key_Shift && key != Qt::Key_Control
- && key != Qt::Key_Alt && key != Qt::Key_Meta)
- hideTip();
+ const int key = static_cast<QKeyEvent *>(e)->key();
+ // Anything except key modifiers or caps-lock, etc.
+ if (key < Qt::Key_Shift || key > Qt::Key_ScrollLock)
+ hideTipImmediately();
break;
}
#endif