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

TextEdit and TextInput can't cope with selectionEnd values smaller than selectionStart

    XMLWordPrintable

Details

    Description

      With the code below the editor draw correctly when clicking and selecting text by dragging right, but not when dragging left of the click position.
      Clicking left of the current cursor position also produce unexpected result.

      Rectangle {
          width: 640; height: 480;
          Rectangle {
              anchors.centerIn: parent
              width: 400; height: 25;
              color: "blue"
      
              TextInput {
                  anchors.fill: parent
                  color: "white"
                  focus: true
                  text: "Sea Shepherd campaigner Peter Bethune faces 15 years in jail after boarding whaling ship"
      
                  MouseArea {
                      anchors.fill: parent
                      onPressed: parent.selectionStart = parent.selectionEnd = parent.xToPosition(mouse.x);
                      onPositionChanged: parent.selectionEnd = parent.xToPosition(mouse.x);
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            wallison Warwick Allison (closed Nokia identity) (Inactive)
            mathiasm Mathias Malmqvist
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes