onActiveFocusChanged: {
selectAll()
if(activeFocus) inputPanelContainer.textDisplay = inputItem.text
}
我认为,为了使这项工作,我需要找到一种结束焦点的好方法,因为目前我似乎无法弄清楚一旦用户完成编辑字符串,我似乎无法在第一个中突出显示焦点相互作用。换句话说,按下Enter Enter Rubsor仍在文本框中,闪烁。
也许有人可以告诉我结束焦点的正确方法,或者有人可以告诉我如何使用MoveCursorselection()或其他某些属性,信号或文本输入方法,这将导致光标位置始终处于末尾字符串后,用户单击“文本输入”框?
为什么您要自己捕获返回键?
我始终使用已存在的为此,它正常工作效果很好。 ActiveFocus是一种仅阅读的属性,因此确实无法正常工作。您可以尝试在thisitemhere thisemhere上的项目甚至顶部窗口上强调forcectivefocus,以从textInput中释放焦点。
,您还可以查看
cursorPosition属性吗?将其设置为
-inputitem.length
我在桌面应用程序中面临着同样的问题。我设法用Mousearea解决了它,但是我没有尝试过,也不知道它是否可与触摸显示一起使用。 i我将鼠标事件传递给了父母,而无需单击Mousearea,它应该做什么:
TextInput {
id: loginInput
anchors.verticalCenter: parent.verticalCenter
leftPadding: 8
topPadding: 4
width: parent.width*0.8
height: 20
KeyNavigation.tab: passwordInput
font.pixelSize: 12
Text {
id:loginPlaceholder
anchors.fill: parent
leftPadding: parent.leftPadding
topPadding: parent.topPadding
text: "Input Login..."
color: "#aaa"
visible: !parent.text
font.italic: true
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
propagateComposedEvents: true
onClicked: {
mouse.accepted = false
parent.focus=true
parent.cursorPosition=parent.positionAt(mouseX,mouseY)
}
onDoubleClicked: parent.selectAll()
}
}
在我的双击事件中,它可以执行您要求的操作。您可以将其移动到现有的事件。