Support for preedit text on predictive keyboards

This commit is contained in:
Angela Mazzurco 2017-07-03 17:03:03 +02:00
parent 161bd4c227
commit 0a17cbefec

View file

@ -229,11 +229,13 @@ Item
onTextChanged: onTextChanged:
{ {
if (msgField.length == 0) var msgLenght = (msgField.preeditText)? msgField.preeditText.length : msgField.length
if (msgLenght == 0)
{ {
sendButton.state = "" sendButton.state = ""
} }
else if (msgField.length > 0) else if (msgLenght > 0 )
{ {
sendButton.state = "SENDBTN" sendButton.state = "SENDBTN"
} }
@ -263,6 +265,10 @@ Item
shiftPressed = false shiftPressed = false
} }
} }
function reset ()
{
Qt.inputMethod.reset()
}
} }
} }
} }
@ -365,9 +371,26 @@ Item
function sendMessage () function sendMessage ()
{ {
if (emojiPicker.state == "EMOJI_SHOWN") emojiPicker.state = "EMOJI_HIDDEN" if (emojiPicker.state == "EMOJI_SHOWN") emojiPicker.state = "EMOJI_HIDDEN"
var jsonData = {"chat_id":chatView.chatId, "msg":msgField.text}
var msgText = getCompleteMessageText()
var jsonData = {"chat_id":chatView.chatId, "msg":msgText}
rsApi.request( "/chat/send_message", JSON.stringify(jsonData), rsApi.request( "/chat/send_message", JSON.stringify(jsonData),
function(par) { msgField.text = ""; } ) function(par)
{
msgField.text = ""
msgField.reset();
})
}
// This function is needed for the compatibility with auto predictive keyboards
function getCompleteMessageText (){
var completeMsg
if (msgField.preeditText) completeMsg = msgField.text + msgField.preeditText
else completeMsg = msgField.text
return completeMsg
} }
} }