mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix input field shortcuts on macOS.
This commit is contained in:
parent
0f234188e1
commit
b80b770631
1 changed files with 8 additions and 4 deletions
|
@ -131,10 +131,14 @@ namespace Platform {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void SendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
void SendKeySequence(Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier) {
|
||||||
const auto focused = QApplication::focusWidget();
|
const auto focused = static_cast<QObject*>(QApplication::focusWidget());
|
||||||
if (qobject_cast<QLineEdit*>(focused) || qobject_cast<QTextEdit*>(focused) || dynamic_cast<HistoryInner*>(focused)) {
|
if (qobject_cast<QLineEdit*>(focused)
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyPress, key, modifiers));
|
|| qobject_cast<QTextEdit*>(focused)
|
||||||
QApplication::postEvent(focused, new QKeyEvent(QEvent::KeyRelease, key, modifiers));
|
|| dynamic_cast<HistoryInner*>(focused)) {
|
||||||
|
QKeyEvent pressEvent(QEvent::KeyPress, key, modifiers);
|
||||||
|
focused->event(&pressEvent);
|
||||||
|
QKeyEvent releaseEvent(QEvent::KeyRelease, key, modifiers);
|
||||||
|
focused->event(&releaseEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue