Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-11042 Add right-to-left locale support to QtQuick elements
  3. QTBUG-17490

Add a way to query the reading direction of text from QML

    XMLWordPrintable

Details

    • 6aaf7b3c93687b857ff7cac0f2ad2ee510b2813b

    Description

      Needed for the text selection of right-to-left text and bi-directional text, and any other use case where the UI behavior depends on the reading direction of the text elements. The text selection handles should align differently on top of the text depending on the reading direction of the text under the selection end and selection start positions, but there is currently no way to query that from QML. In C++ side this can be achieved using method QString::isRightToLeft().

      The API could be Qt::isRightToLeft(string) or TextEdit::isRightToLeft(posStart, posEnd).

      TextEdit {
          SelectionHandle {
              id: startHandle
              x: editor.positionToRectangle(editor.selectionStart) + Qt.isRightToLeft(startCursorText) ? editor.width : 0
              property string startCursorText: editor.text.substr(editor.selectionStart, editor.selectionStart+1)
          } 
          SelectionHandle {
              id: endHandle
              x: editor.positionToRectangle(editor.selectionEnd) + Qt.isRightToLeft(endCursorText) ? 0 : -editor.width
              property string endCursorText: editor.text.substr(editor.selectionEnd, editor.selectionEnd+1)
          } 
      }
      

      Attachments

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

        Activity

          People

            jpetrell Joona Petrell
            jpetrell Joona Petrell
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes