diff options
Diffstat (limited to 'desktop/assistant/Card.qml')
| -rw-r--r-- | desktop/assistant/Card.qml | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/desktop/assistant/Card.qml b/desktop/assistant/Card.qml index 543edd1..ab80d1b 100644 --- a/desktop/assistant/Card.qml +++ b/desktop/assistant/Card.qml @@ -34,6 +34,21 @@ Rectangle { Component.onCompleted: input.forceActiveFocus() + // Focus falls out of the card when its holder goes: the history field + // hiding, or a streaming reply's text rebuilt under a click. With the + // keyboard grabbed, nothing would then reach Escape. Give it back. + Connections { + target: card.Window.window + function onActiveFocusItemChanged() { + const f = card.Window.activeFocusItem; + if (!f || f === card.Window.contentItem) Qt.callLater(() => input.forceActiveFocus()); + } + } + Connections { + target: card.canvas + function onHistoryOpenChanged() { if (!card.canvas.historyOpen) input.forceActiveFocus(); } + } + // --- header --- Item { @@ -91,6 +106,7 @@ Rectangle { // Follow the bottom while a reply streams, unless the user scrolled // up to read; scrolling back to the end resumes following. property bool stick: true + onMovementStarted: stick = false onMovementEnded: stick = atYEnd onContentHeightChanged: if (stick) Qt.callLater(positionViewAtEnd) Component.onCompleted: positionViewAtEnd() @@ -153,7 +169,9 @@ Rectangle { width: scroller.width wrapMode: TextEdit.Wrap selectByMouse: true - enabled: card.canvas.connected + // readOnly, not disabled: a disabled item cannot hold the + // focus that Escape needs to reach the card. + readOnly: !card.canvas.connected color: Theme.text font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } onCursorRectangleChanged: scroller.follow(cursorRectangle) |
