diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index ce4d8efce..5214c0b09 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -131,10 +131,14 @@ namespace Platform { namespace { void SendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) { - const auto focused = QApplication::focusWidget(); - if (qobject_cast(focused) || qobject_cast(focused) || dynamic_cast(focused)) { - QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers)); - QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers)); + const auto focused = static_cast(QApplication::focusWidget()); + if (qobject_cast(focused) + || qobject_cast(focused) + || dynamic_cast(focused)) { + QKeyEvent pressEvent(QEvent::KeyPress, key, modifiers); + focused->event(&pressEvent); + QKeyEvent releaseEvent(QEvent::KeyRelease, key, modifiers); + focused->event(&releaseEvent); } }