Restore focus to previous item on console exit

This commit is contained in:
miruka 2019-12-09 13:34:56 -04:00
parent 37d8d5c68d
commit 9c70e08668

View File

@ -16,6 +16,8 @@ HDrawer {
z: 9999 z: 9999
position: 0 position: 0
property var previouslyFocusedItem: null
property var target: null property var target: null
property alias t: debugConsole.target property alias t: debugConsole.target
@ -53,7 +55,6 @@ HDrawer {
mainUI.shortcuts.debugConsole.destroy() mainUI.shortcuts.debugConsole.destroy()
mainUI.shortcuts.debugConsole = debugConsole mainUI.shortcuts.debugConsole = debugConsole
forceActiveFocus()
position = 1 position = 1
commandsView.model.insert(0, { commandsView.model.insert(0, {
input: "t = " + String(target), input: "t = " + String(target),
@ -62,6 +63,15 @@ HDrawer {
}) })
} }
onVisibleChanged: {
if (visible) {
previouslyFocusedItem = window.activeFocusItem
forceActiveFocus()
} else if (previouslyFocusedItem) {
previouslyFocusedItem.forceActiveFocus()
}
}
onHistoryEntryChanged: onHistoryEntryChanged:
inputField.text = inputField.text =
historyEntry === -1 ? "" : history.slice(-historyEntry - 1)[0] historyEntry === -1 ? "" : history.slice(-historyEntry - 1)[0]