0
我使用Qt5.7.1 在iOS系统中长按QML的TextInput显示与选择本地上下文菜单时停止本地上下文菜单的iOS上的显示/全选/粘贴物品。如何防止显示此菜单,同时允许TextInput仍然可编辑。如何使用QML的TextInput
如果我使用Qt 5.6.2,TextInput不显示这样的菜单。
使用下面的代码,我可以阻止在5.7.1中显示上下文菜单,但是光标位置总是在文本的末尾结束。
import QtQuick 2.5
import QtQuick.Window 2.0
Rectangle
{
color: "yellow"
width: 100; height: 100
Rectangle {
color: "white"
width: 100; height: 50
anchors.centerIn: parent
TextInput{
id:tip
text:"test123"
anchors.fill: parent
onActiveFocusChanged: {
console.log("tip onActiveFocusChanged")
}
onCursorPositionChanged: {
console.log("onCursorPositionChanged:" + tip.cursorPosition)
}
MouseArea {
id:ma
anchors.fill: parent
propagateComposedEvents:true
onPressed: {
console.log("ma onPressed:" + tip.cursorPosition)
mouse.accepted = true
tip.focus = false;
}
onClicked: {
console.log("ma onClicked:" + tip.cursorPosition)
mouse.accepted = false
tip.forceActiveFocus();
}
onPressAndHold:{
console.log("ma onPressAndHold")
mouse.accepted = true
tip.focus = false;
}
}
}
}
}
我不知道是否有更好的方法可以做到这一点,也有一个完全可编辑的TextInput。