Make DebugConsole keyboard-scrollable

This commit is contained in:
miruka 2019-12-09 13:00:42 -04:00
parent 6e6fa0ad35
commit 718aef8414
2 changed files with 20 additions and 14 deletions

View File

@ -44,6 +44,8 @@ HDrawer {
.h, .help Show this help`.replace(/^ {8}/gm, "")
)
readonly property alias commandsView: commandsView
Component.onCompleted: {
if (mainUI.shortcuts.debugConsole)

View File

@ -15,6 +15,10 @@ Item {
// DebugConsole that should be affected by console shortcuts
property DebugConsole debugConsole
readonly property Item toFlick:
debugConsole && debugConsole.activeFocus ?
debugConsole.commandsView : flickTarget
// App
@ -66,46 +70,46 @@ Item {
// Page scrolling
HShortcut {
enabled: flickTarget
enabled: toFlick
sequences: settings.keys.scrollUp
onActivated: Utils.smartVerticalFlick(flickTarget, -335)
onActivated: Utils.smartVerticalFlick(toFlick, -335)
}
HShortcut {
enabled: flickTarget
enabled: toFlick
sequences: settings.keys.scrollDown
onActivated: Utils.smartVerticalFlick(flickTarget, 335)
onActivated: Utils.smartVerticalFlick(toFlick, 335)
}
HShortcut {
enabled: flickTarget
enabled: toFlick
sequences: settings.keys.scrollPageUp
onActivated: Utils.smartVerticalFlick(
flickTarget, -2.3 * flickTarget.height, 8,
toFlick, -2.3 * toFlick.height, 8,
)
// Ensure only a slight slip after releasing the key
// onReleased: Utils.smartVerticalFlick(flickTarget, -335)
// onReleased: Utils.smartVerticalFlick(toFlick, -335)
}
HShortcut {
enabled: flickTarget
enabled: toFlick
sequences: settings.keys.scrollPageDown
onActivated: Utils.smartVerticalFlick(
flickTarget, 2.3 * flickTarget.height, 8,
toFlick, 2.3 * toFlick.height, 8,
)
// onReleased: Utils.smartVerticalFlick(flickTarget, 335)
// onReleased: Utils.smartVerticalFlick(toFlick, 335)
}
HShortcut {
enabled: flickTarget
enabled: toFlick
sequences: settings.keys.scrollToTop
onActivated: Utils.flickToTop(flickTarget)
onActivated: Utils.flickToTop(toFlick)
}
HShortcut {
enabled: flickTarget
enabled: toFlick
sequences: settings.keys.scrollToBottom
onActivated: Utils.flickToBottom(flickTarget)
onActivated: Utils.flickToBottom(toFlick)
}