Add arrow navigation to sidepane when focused

This commit is contained in:
miruka 2019-08-20 13:41:55 -04:00
parent 203eb3b299
commit 073a2eacee
2 changed files with 20 additions and 5 deletions

View File

@ -57,15 +57,19 @@ HListView {
model.source = show model.source = show
} }
function previous() { function previous(activate=true) {
decrementCurrentIndex() decrementCurrentIndex()
activateLimiter.requestFire() if (activate) activateLimiter.requestFire()
} }
function next() { function next(activate=true) {
incrementCurrentIndex() incrementCurrentIndex()
activateLimiter.requestFire() if (activate) activateLimiter.requestFire()
}
function activate() {
currentItem.item.activate()
} }
function toggleCollapseAccount() { function toggleCollapseAccount() {
@ -109,7 +113,7 @@ HListView {
HRateLimiter { HRateLimiter {
id: activateLimiter id: activateLimiter
onFired: currentItem.item.activate() onFired: activate()
extendOnRequestWhileCooldownActive: true extendOnRequestWhileCooldownActive: true
} }
} }

View File

@ -82,6 +82,17 @@ HRectangle {
} }
Keys.enabled: sidePane.hasFocus
Keys.onUpPressed: accountRoomList.previous(false) // do not activate
Keys.onDownPressed: accountRoomList.next(false)
Keys.onEnterPressed: Keys.onReturnPressed(event)
Keys.onReturnPressed: if (event.modifiers & Qt.ShiftModifier) {
accountRoomList.toggleCollapseAccount()
} else {
accountRoomList.activate()
}
HColumnLayout { HColumnLayout {
anchors.fill: parent anchors.fill: parent