WinRT: Handle back button as press or release
Earlier, only the back press was checked for acceptance. By also checking the release event, this makes the backstepping behavior consistent with Qt for Android, and fixes the expected behavior found in our demo applications. Task-number: QTBUG-35951 Change-Id: I9c2f18816b838d57713ba4dd3624e2f3f1ac40ac Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>bb10
parent
878da15f2c
commit
c97edb2579
|
|
@ -1020,7 +1020,9 @@ HRESULT QWinRTScreen::onOrientationChanged(IInspectable *)
|
|||
HRESULT QWinRTScreen::onBackButtonPressed(IInspectable *, IBackPressedEventArgs *args)
|
||||
{
|
||||
QKeyEvent backPress(QEvent::KeyPress, Qt::Key_Back, Qt::NoModifier);
|
||||
QKeyEvent backRelease(QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier);
|
||||
backPress.setAccepted(false);
|
||||
backRelease.setAccepted(false);
|
||||
|
||||
QObject *receiver = m_visibleWindows.isEmpty()
|
||||
? static_cast<QObject *>(QGuiApplication::instance())
|
||||
|
|
@ -1028,12 +1030,8 @@ HRESULT QWinRTScreen::onBackButtonPressed(IInspectable *, IBackPressedEventArgs
|
|||
|
||||
// If the event is ignored, the app will suspend
|
||||
QGuiApplication::sendEvent(receiver, &backPress);
|
||||
if (backPress.isAccepted()) {
|
||||
args->put_Handled(true);
|
||||
// If the app accepts the event, send the release for symmetry
|
||||
QKeyEvent backRelease(QEvent::KeyRelease, Qt::Key_Back, Qt::NoModifier);
|
||||
QGuiApplication::sendEvent(receiver, &backRelease);
|
||||
}
|
||||
QGuiApplication::sendEvent(receiver, &backRelease);
|
||||
args->put_Handled(backPress.isAccepted() || backRelease.isAccepted());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue