Fix cursor position when inserting emoji
BUG: 456641
This commit is contained in:
@@ -15,6 +15,7 @@ QQC2.ToolBar {
|
||||
property alias inputFieldText: inputField.text
|
||||
property alias textField: inputField
|
||||
property alias emojiPaneOpened: emojiButton.checked
|
||||
property alias cursorPosition: inputField.cursorPosition
|
||||
|
||||
signal closeAllTriggered()
|
||||
signal inputFieldForceActiveFocusTriggered()
|
||||
|
||||
@@ -66,7 +66,7 @@ ColumnLayout {
|
||||
Kirigami.Theme.colorSet: Kirigami.Theme.View
|
||||
contentItem: EmojiPicker {
|
||||
textArea: chatBar.textField
|
||||
onChosen: addText(emoji)
|
||||
onChosen: insertText(emoji)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,12 +128,10 @@ ColumnLayout {
|
||||
}
|
||||
}
|
||||
|
||||
function addText(text) {
|
||||
chatBox.inputFieldText = inputFieldText + text
|
||||
}
|
||||
|
||||
function insertText(str) {
|
||||
chatBox.inputFieldText = inputFieldText.substr(0, inputField.cursorPosition) + str + inputFieldText.substr(inputField.cursorPosition)
|
||||
let index = chatBar.cursorPosition;
|
||||
chatBox.inputFieldText = inputFieldText.substr(0, chatBar.cursorPosition) + str + inputFieldText.substr(chatBar.cursorPosition);
|
||||
chatBar.cursorPosition = index + str.length;
|
||||
}
|
||||
|
||||
function focusInputField() {
|
||||
|
||||
Reference in New Issue
Block a user