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

Enable better text cursor control from QML

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.9.1
    • None

    Description

      Text cursor control from QML is mediocre:

      TextField from Controls 1.4 has only the ability to set the cursor position as an integer, and that's it.

      The older TextEdit is actually better off, but by a minuscule fraction. It has the additional selectWord() and moveCursorSelection(int position, SelectionMode mode), but mode is limited to either selecting characters or words.

      Looking at the internals, there is a treasure trove of cursor operations:

       

      enum MoveOperation {
          NoMove,
          Start,
          Up,
          StartOfLine,
          StartOfBlock,
          StartOfWord,
          PreviousBlock,
          PreviousCharacter,
          PreviousWord,
          Left,
          WordLeft,
          End,
          Down,
          EndOfLine,
          EndOfWord,
          EndOfBlock,
          NextBlock,
          NextCharacter,
          NextWord,
          Right,
          WordRight,
          NextCell,
          PreviousCell,
          NextRow,
          PreviousRow
      };

      I don't see any good reason why those would be tucked away and completely inaccessible from the public API.

      Especially considering how useful they can be in QML, which is very often, if not predominantly, used to target mobile devices that don't have physical keyboards, and whose on screen keyboards don't have the keys to invoke those cursor move operations.

      Additionally, anyone who has ever tried it knows that precise text cursor control via touch is horrid, it is difficult and awkward to to precise selections or get to a specific place in the text.

      I am currently using a hacky approach to get it (https://bugreports.qt.io/browse/QTBUG-62948) which has a problem with getting to build on top of the fact it uses private implementations that are subject to change and breakage and the doom warnings in Creator for including private modules in the project.

      I think having that functionality as part of the public API will have a lot of benefits without having any drawbacks. Furthermore, as evident from the linked implementation, it will be trivial to expose it to the public API.

      Attachments

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

        Activity

          People

            srutledg Shawn Rutledge
            dgo dgo
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes