Answer the question
In order to leave comments, you need to log in
Why in TextFild(qml), if a mask is set, does the cursor not change position correctly?
In the qml TextField, if inputMask is set, the cursor (when entering text) moves one position, but it should, depending on the mask.
This problem manifests itself on android. On a desktop with a physical keyboard, the behavior is correct
import QtQuick 2.14
import QtQuick.Window 2.14
import QtQuick.Controls 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Item {
anchors.fill: parent
Column{
spacing: 10
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: parent.top
anchors.topMargin: 20
TextField{
id: text_field
// inputMethodHints: Qt.ImhNoPredictiveText|Qt.ImhSensitiveData | Qt.ImhDigitsOnly
inputMethodHints: Qt.ImhDigitsOnly
inputMask: "+7(###)-###-####"
onTextChanged: {
console.log("text changed")
}
Keys.onPressed: {
console.log("keys presed "+ event.key)
text_event.text= "keys presed "+ event.key
}
onFocusChanged: {
if(focus){
cursorPosition=0
}
}
}
Text {
text: text_field.text
}
Text {
id: text_event
}
}
}
}
Answer the question
In order to leave comments, you need to log in
I had a slightly different problem with inputMask.
inputMask: ">NNNNNN-NNNNNN-NNNNNN-NNNNNN-NNNNNN-NNNNNN;#"
inputMethodHints: Qt.ImhSensitiveData | Qt.ImhPreferUppercase | Qt.ImhNoPredictiveText
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question