From a61719ddc40dab334d3fa617f064b225b164e7f6 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 14 Jul 2022 16:35:29 +0100 Subject: [PATCH] Accept keys in windowheap conditionally In WindowHeap we currently always accept the keyboard event regardless of whether the event was handled. This will allow the event to propagate to other handlers --- src/effects/private/qml/WindowHeap.qml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/effects/private/qml/WindowHeap.qml b/src/effects/private/qml/WindowHeap.qml index b5eeff762e..b110de265e 100644 --- a/src/effects/private/qml/WindowHeap.qml +++ b/src/effects/private/qml/WindowHeap.qml @@ -244,7 +244,9 @@ FocusScope { const nextIndex = findNextItem(heap.selectedIndex, direction); if (nextIndex != -1) { heap.selectedIndex = nextIndex; + return true; } + return false; } function selectLastItem(direction) { @@ -259,39 +261,43 @@ FocusScope { } if (last != -1) { heap.selectedIndex = last; + return true; } + return false; } onActiveFocusChanged: resetSelected(); Keys.onPressed: { + let handled = false; switch (event.key) { case Qt.Key_Up: - selectNextItem(WindowHeap.Direction.Up); + handled = selectNextItem(WindowHeap.Direction.Up); break; case Qt.Key_Down: - selectNextItem(WindowHeap.Direction.Down); + handled = selectNextItem(WindowHeap.Direction.Down); break; case Qt.Key_Left: - selectNextItem(WindowHeap.Direction.Left); + handled = selectNextItem(WindowHeap.Direction.Left); break; case Qt.Key_Right: - selectNextItem(WindowHeap.Direction.Right); + handled = selectNextItem(WindowHeap.Direction.Right); break; case Qt.Key_Home: - selectLastItem(WindowHeap.Direction.Left); + handled = selectLastItem(WindowHeap.Direction.Left); break; case Qt.Key_End: - selectLastItem(WindowHeap.Direction.Right); + handled = selectLastItem(WindowHeap.Direction.Right); break; case Qt.Key_PageUp: - selectLastItem(WindowHeap.Direction.Up); + handled = selectLastItem(WindowHeap.Direction.Up); break; case Qt.Key_PageDown: - selectLastItem(WindowHeap.Direction.Down); + handled = selectLastItem(WindowHeap.Direction.Down); break; case Qt.Key_Return: case Qt.Key_Space: + handled = true; let selectedItem = null; if (heap.selectedIndex != -1) { selectedItem = windowsRepeater.itemAt(heap.selectedIndex); @@ -316,6 +322,6 @@ FocusScope { default: return; } - event.accepted = true; + event.accepted = handled; } }