Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all
Unified · Split
| @@ -3705,7 +3705,10 @@ static bool _altPressed{ false }; · 3704 unmodified lines | |||
| 3705 | 3705 | ||
| 3706 | void Application::keyPressEvent(QKeyEvent* event) { | 3706 | void Application::keyPressEvent(QKeyEvent* event) { |
| 3707 | _altPressed = event->key() == Qt::Key_Alt; | 3707 | _altPressed = event->key() == Qt::Key_Alt; |
| 3708 | _keysPressed.insert(event->key()); | 3708 | |
| 3709 | if (!event->isAutoRepeat()) { | ||
| 3710 | _keysPressed.insert(event->key(), *event); | ||
| 3711 | } | ||
| 3709 | 3712 | ||
| 3710 | _controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts | 3713 | _controllerScriptingInterface->emitKeyPressEvent(event); // send events to any registered scripts |
| 3711 | // if one of our scripts have asked to capture this event, then stop processing it | 3714 | // if one of our scripts have asked to capture this event, then stop processing it |
| @@ -3916,7 +3919,9 @@ void Application::keyPressEvent(QKeyEvent* event) { · 204 unmodified lines | |||
| 3916 | } | 3919 | } |
| 3917 | 3920 | ||
| 3918 | void Application::keyReleaseEvent(QKeyEvent* event) { | 3921 | void Application::keyReleaseEvent(QKeyEvent* event) { |
| 3919 | _keysPressed.remove(event->key()); | 3922 | if (!event->isAutoRepeat()) { |
| 3923 | _keysPressed.remove(event->key()); | ||
| 3924 | } | ||
| 3920 | 3925 | ||
| 3921 | #if defined(Q_OS_ANDROID) | 3926 | #if defined(Q_OS_ANDROID) |
| 3922 | if (event->key() == Qt::Key_Back) { | 3927 | if (event->key() == Qt::Key_Back) { |
| @@ -3952,11 +3957,14 @@ void Application::focusOutEvent(QFocusEvent* event) { · 29 unmodified lines | |||
| 3952 | #endif | 3957 | #endif |
| 3953 | 3958 | ||
| 3954 | // synthesize events for keys currently pressed, since we may not get their release events | 3959 | // synthesize events for keys currently pressed, since we may not get their release events |
| 3955 | foreach (int key, _keysPressed) { | 3960 | // Because our key event handlers may manipulate _keysPressed, lets swap the keys pressed into a local copy, |
| 3956 | QKeyEvent keyEvent(QEvent::KeyRelease, key, Qt::NoModifier); | 3961 | // clearing the existing list. |
| 3957 | keyReleaseEvent(&keyEvent); | 3962 | QHash<int, QKeyEvent> keysPressed; |
| 3963 | std::swap(keysPressed, _keysPressed); | ||
| 3964 | for (auto& ev : keysPressed) { | ||
| 3965 | QKeyEvent synthesizedEvent { QKeyEvent::KeyRelease, ev.key(), Qt::NoModifier, ev.text() }; | ||
| 3966 | keyReleaseEvent(&synthesizedEvent); | ||
| 3958 | } | 3967 | } |
| 3959 | _keysPressed.clear(); | ||
| 3960 | } | 3968 | } |
| 3961 | 3969 | ||
| 3962 | void Application::maybeToggleMenuVisible(QMouseEvent* event) const { | 3970 | void Application::maybeToggleMenuVisible(QMouseEvent* event) const { |