Import keyboard navigation

* Aggressively set focus to message input box and fix #37
* Improve room switching #66
This commit is contained in:
Carl Schwan
2020-11-28 00:25:40 +01:00
parent 2a0b6c74f3
commit 4bff186a40
2 changed files with 31 additions and 0 deletions

View File

@@ -34,6 +34,10 @@ ToolBar {
position: ToolBar.Footer
function addText(text) {
inputField.insert(inputField.length, text)
}
contentItem: ColumnLayout {
id: layout
spacing: 0
@@ -235,6 +239,7 @@ ToolBar {
room: currentRoom ?? null
}
Layout.fillWidth: true
@@ -296,13 +301,34 @@ ToolBar {
Keys.onEscapePressed: closeAll()
Keys.onPressed: {
if (event.key === Qt.Key_PageDown) {
switchRoomDown();
} else if (event.key === Qt.Key_PageUp) {
switchRoomUp();
} else if (!(event.modifiers & Qt.ControlModifier)) {
event.accepted = true;
chatTextInput.addText(event.text);
chatTextInput.focus();
return;
}
}
Keys.onBacktabPressed: {
if (event.modifiers & Qt.ControlModifier) {
switchRoomUp();
return;
}
if (isAutoCompleting) {
autoCompleteListView.decrementCurrentIndex();
}
}
Keys.onTabPressed: {
if (event.modifiers & Qt.ControlModifier) {
switchRoomDown();
return;
}
if (!isAutoCompleting) {
return;
}

View File

@@ -49,6 +49,11 @@ Kirigami.ScrollablePage {
switchRoomDown();
} else if (event.key === Qt.Key_PageUp) {
switchRoomUp();
} else if (!(event.modifiers & Qt.ControlModifier)) {
event.accepted = true;
chatTextInput.addText(event.text);
chatTextInput.focus();
return;
}
}