From 348a8186fd87d1ed6fd36c3edcd5c8521b838e04 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 26 Nov 2018 12:32:00 +0800 Subject: [PATCH] Fix #121 and #119. --- imports/Spectral/Panel/RoomPanelInput.qml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index 6e1bdd5..89ef04a 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -13,12 +13,12 @@ import Spectral 0.1 import "qrc:/js/md.js" as Markdown Control { - property bool isReply + property alias isReply: replyItem.visible property var replyUser property string replyEventID property string replyContent - property bool isAutoCompleting + property alias isAutoCompleting: autoCompleteListView.visible property var autoCompleteModel property int autoCompleteBeginPosition property int autoCompleteEndPosition @@ -46,7 +46,7 @@ Control { id: replyItem - visible: isReply + visible: false spacing: 8 @@ -86,7 +86,7 @@ Control { id: autoCompleteListView - visible: isAutoCompleting && model.length !== 0 + visible: false model: autoCompleteModel @@ -258,12 +258,15 @@ Control { Keys.onReturnPressed: { if (event.modifiers & Qt.ShiftModifier) { insert(cursorPosition, "\n") - } else { + } else if (text) { postMessage(text) text = "" + closeAll() } } + Keys.onEscapePressed: closeAll() + Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex() Keys.onTabPressed: { @@ -318,7 +321,6 @@ Control { if (isReply) { currentRoom.sendReply(replyUser.id, replyEventID, replyContent, text) - clearReply() return } @@ -393,4 +395,10 @@ Control { function focus() { inputField.forceActiveFocus() } + + function closeAll() { + replyItem.visible = false + autoCompleteListView.visible = false + emojiPicker.visible = false + } }