i had a problem with scrolable TextInput and i haven’t seen any questions on the topic on the forums.
I was trying to decide problem with ListView, but because delegate blocks a function sendMSG it didn’t work out. Finally I used ScrollView and property contentWidth and it helped me.
My Code
Rectangle{
id:sendArea
implicitWidth: userChat1.width*0.9
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom:parent.bottom
anchors.bottomMargin: 10
implicitHeight: 60
clip:true
color: "#f4f3f7"
radius: 16
ScrollView{
width: parent.width*0.78
height: parent.height
anchors.left: parent.left
anchors.leftMargin: 10
contentWidth: width
TextInput
{
autoScroll : true
id: youreTextInput
color: "#000000"
font.pointSize: 18
width: sendArea.width*0.74
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 10
wrapMode: Text.Wrap
}
}
Button{
id:sendButt
onClicked: sendMSG();
anchors.right: sendArea.right
anchors.rightMargin: 10
anchors.verticalCenter: sendArea.verticalCenter
background: Rectangle{
anchors.centerIn: parent
color:"#29303C"
height: sendArea.height*0.8
width: height
radius: height/2
Text {
text: StackView.depth?"u15C6":"u15C6"
color: "#ffffff"
font.pointSize: 24
anchors.centerIn: parent
}
}
}
}
function sendMSG(){
if(youreTextInput.text == "")
return;
var isSender = Math.random() > 0.5;
console.log("Sending mesage");
var currentTime = new Date();
var hours = currentTime.getHours() < 10 ? "0" + currentTime.getHours() : currentTime.getHours();
var minutes = currentTime.getMinutes() < 10 ? "0" + currentTime.getMinutes() : currentTime.getMinutes();
chatHistory.append({
"sender": isSender,
"message": youreTextInput.text,
"time": hours + ":" + minutes
});
youreTextInput.text = "";
}
I hope this helps to someone