Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-48174

QML TextEdit inside Flickable becomes non-interactive

    XMLWordPrintable

Details

    • 265b3bea18c1ac13da413931024f64f49a2da7fc

    Description

      Given a TextEdit inside a Flickable example from TextEdit documetation:

      • Input enough text to be able to flick
      • Flick to the bottom of the text
      • Click on the text
      • EXPECTED: Cursor appears positioned at the click location
      • ACTUAL: Cursor doesn't appear

      Clicks in the upper region of TextEdit work as expected. It seems to me TexEdit's interactive area doesn't extend to the whole of the Flickable.

      main.qml
      import QtQuick 2.3
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 400
          height: 300
      
          Rectangle {
              anchors.fill: parent
      
      
              Flickable {
                  id: flick
      
                  anchors.fill: parent
                  contentWidth: edit.paintedWidth
                  contentHeight: edit.paintedHeight
                  clip: true
      
                  flickableDirection: Flickable.VerticalFlick
      
                  function ensureVisible(r)
                  {
                      if (contentX >= r.x)
                          contentX = r.x;
                      else if (contentX+width <= r.x+r.width)
                          contentX = r.x+r.width-width;
                      if (contentY >= r.y)
                          contentY = r.y;
                      else if (contentY+height <= r.y+r.height)
                          contentY = r.y+r.height-height;
                  }
      
                  //uncomment for a workaround
      //            MouseArea{
      //                anchors.fill: parent
      //                onPressed: edit.cursorPosition = edit.positionAt(mouseX, mouseY)
      //            }
      
                  //uncomment to show Flickable area
      //            Rectangle{
      //                anchors.fill: parent
      //                border.width: 10
      //                border.color: "cyan"
      //                color: "transparent"
      //            }
      
                  TextEdit {
                      id: edit
                      width: flick.width
                      height: flick.height
                      focus: true
                      wrapMode: TextEdit.Wrap
                      onCursorRectangleChanged: flick.ensureVisible(cursorRectangle)
                      text: "Nulla porttitor accumsan tincidunt. Proin eget tortor risus." +
                              "Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;"+
                              "Donec velit neque, auctor sit amet aliquam vel, ullamcorper sit amet ligula. Donec rutrum congue leo eget malesuada." +
                              "Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a."+
                              "Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus."+
                              "Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Nulla quis lorem ut libero malesuada feugiat."+
                              "Nulla quis lorem ut libero malesuada feugiat.\n\n"+
      
                              "Proin eget tortor risus. Sed porttitor lectus nibh. Sed porttitor lectus nibh."+
                              "Nulla quis lorem ut libero malesuada feugiat. Cras ultricies ligula sed magna dictum porta."+
                              "Praesent sapien massa, convallis a pellentesque nec, egestas non nisi. Donec rutrum congue leo eget malesuada."+
                              "Cras ultricies ligula sed magna dictum porta. Quisque velit nisi, pretium ut lacinia in, elementum id enim."+
                              "Quisque velit nisi, pretium ut lacinia in, elementum id enim."
      
                      //uncomment to show TextEdit area
      //                Rectangle{
      //                    anchors.fill: parent
      //                    border.width: 5
      //                    color: "transparent"
      //                }
      
                  }
              }
      
      
          }
      }
      
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            Velenir Velenri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes