diff --git a/imports/Spectral/Panel/RoomPanelInput.qml b/imports/Spectral/Panel/RoomPanelInput.qml index 41bc6b3..da62e06 100644 --- a/imports/Spectral/Panel/RoomPanelInput.qml +++ b/imports/Spectral/Panel/RoomPanelInput.qml @@ -80,6 +80,11 @@ Rectangle { } text: modelData.displayName + + onClicked: { + userAutoCompleteListView.currentIndex = index + inputField.replaceAutoComplete(displayName) + } } } } @@ -203,9 +208,8 @@ Rectangle { isAutoCompleting = true autoCompleteEndPosition = cursorPosition } - remove(autoCompleteBeginPosition, autoCompleteEndPosition) - autoCompleteEndPosition = autoCompleteBeginPosition + userAutoCompleteListView.currentItem.displayName.length - insert(cursorPosition, userAutoCompleteListView.currentItem.displayName) + + replaceAutoComplete(userAutoCompleteListView.currentItem.displayName) } onTextChanged: { @@ -215,9 +219,16 @@ Rectangle { if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) { isAutoCompleting = false + userAutoCompleteListView.currentIndex = 0 } } + function replaceAutoComplete(word) { + remove(autoCompleteBeginPosition, autoCompleteEndPosition) + autoCompleteEndPosition = autoCompleteBeginPosition + word.length + insert(cursorPosition, word) + } + function postMessage(text) { if (text.trim().length === 0) { return } if(!currentRoom) { return }