Allow clicking autocomplete.
This commit is contained in:
@@ -80,6 +80,11 @@ Rectangle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
text: modelData.displayName
|
text: modelData.displayName
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
userAutoCompleteListView.currentIndex = index
|
||||||
|
inputField.replaceAutoComplete(displayName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -203,9 +208,8 @@ Rectangle {
|
|||||||
isAutoCompleting = true
|
isAutoCompleting = true
|
||||||
autoCompleteEndPosition = cursorPosition
|
autoCompleteEndPosition = cursorPosition
|
||||||
}
|
}
|
||||||
remove(autoCompleteBeginPosition, autoCompleteEndPosition)
|
|
||||||
autoCompleteEndPosition = autoCompleteBeginPosition + userAutoCompleteListView.currentItem.displayName.length
|
replaceAutoComplete(userAutoCompleteListView.currentItem.displayName)
|
||||||
insert(cursorPosition, userAutoCompleteListView.currentItem.displayName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
@@ -215,9 +219,16 @@ Rectangle {
|
|||||||
|
|
||||||
if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) {
|
if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) {
|
||||||
isAutoCompleting = false
|
isAutoCompleting = false
|
||||||
|
userAutoCompleteListView.currentIndex = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function replaceAutoComplete(word) {
|
||||||
|
remove(autoCompleteBeginPosition, autoCompleteEndPosition)
|
||||||
|
autoCompleteEndPosition = autoCompleteBeginPosition + word.length
|
||||||
|
insert(cursorPosition, word)
|
||||||
|
}
|
||||||
|
|
||||||
function postMessage(text) {
|
function postMessage(text) {
|
||||||
if (text.trim().length === 0) { return }
|
if (text.trim().length === 0) { return }
|
||||||
if(!currentRoom) { return }
|
if(!currentRoom) { return }
|
||||||
|
|||||||
Reference in New Issue
Block a user