effects/overview: allow entering spaces in search field
In the Overview effect, pressing the space bar doesn't always insert a space character into the search field as one would expect; when the text in the search field matches any windows, it instead activates the highlighted window. At other times, it does insert a space as expected. This behavior is unpredictable and unintuitive, so this commit fixes the issue by intercepting the key input event and inserting a space when the search field has focus. In this state, the highlighted window can be activated using the enter/return key. When the search field doesn't have focus, a press of the space bar will continue to activate the selected window.
This commit is contained in:
parent
00c0f29f8e
commit
39612ade13
2 changed files with 13 additions and 3 deletions
|
@ -40,7 +40,6 @@ FocusScope {
|
|||
|
||||
Keys.onEscapePressed: effect.deactivate();
|
||||
|
||||
Keys.priority: Keys.AfterItem
|
||||
Keys.forwardTo: searchField
|
||||
|
||||
Keys.onEnterPressed: {
|
||||
|
@ -209,6 +208,7 @@ FocusScope {
|
|||
effect.searchText = text;
|
||||
heap.resetSelected();
|
||||
heap.selectNextItem(WindowHeap.Direction.Down);
|
||||
searchField.focus = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -309,37 +309,47 @@ FocusScope {
|
|||
return false;
|
||||
}
|
||||
|
||||
onActiveFocusChanged: resetSelected();
|
||||
|
||||
Keys.onPressed: {
|
||||
let handled = false;
|
||||
switch (event.key) {
|
||||
case Qt.Key_Up:
|
||||
handled = selectNextItem(WindowHeap.Direction.Up);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_Down:
|
||||
handled = selectNextItem(WindowHeap.Direction.Down);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_Left:
|
||||
handled = selectNextItem(WindowHeap.Direction.Left);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_Right:
|
||||
handled = selectNextItem(WindowHeap.Direction.Right);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_Home:
|
||||
handled = selectLastItem(WindowHeap.Direction.Left);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_End:
|
||||
handled = selectLastItem(WindowHeap.Direction.Right);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_PageUp:
|
||||
handled = selectLastItem(WindowHeap.Direction.Up);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_PageDown:
|
||||
handled = selectLastItem(WindowHeap.Direction.Down);
|
||||
heap.focus = true;
|
||||
break;
|
||||
case Qt.Key_Return:
|
||||
case Qt.Key_Space:
|
||||
if (!heap.focus) {
|
||||
break;
|
||||
}
|
||||
case Qt.Key_Return:
|
||||
handled = false;
|
||||
let selectedItem = null;
|
||||
if (selectedIndex !== -1) {
|
||||
|
|
Loading…
Reference in a new issue