2017-08-14 24 views
0

Qt5.7.1を使用しています iOSで長押しのQML TextInputは、Select/Select All/Paste項目でネイティブコンテキストメニューを表示します。このメニューが表示されないようにするにはどうすればいいのですが、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もあります。

答えて

0

私は以下のハックとiOSの表示から編集メニューを停止することができます:

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 
      MouseArea { 
       id:ma 
       anchors.fill: parent 
       propagateComposedEvents:true 


       onPressed: { 
        mouse.accepted = false 
        tip.focus = false 
        tip.focus = true 
       } 
      } 
      onSelectedTextChanged:tip.deselect() 

     } 
    } 
} 
\
関連する問題