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

[Macintosh] QLineEdit doesn't handle Delete with modifiers correctly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.9.3, 5.11.2
    • QPA
    • None
    • Qt 5.9.3

      OS X 10.12.6

      I doubt either of those are important to the problem
    • macOS

    Description

      A QLineEdit doesn't handle (modifier)+Delete key combinations correctly.

      To reproduce:

      1) Paste some text with words into a QLineEdit (say, "Paste some text with words")

      2) Click somewhere in a space in the middle of the text.

      3) Hold down the Option key and press Delete. That is 

      QKeySequence::DeleteStartOfWord. It deletes the word before the cursor, as expected.

      4) Keep doing that until the cursor is at the start of the text. Now it deletes the character to the right of the cursor. *** That's a bug ***

       

      Another:

      1) Paste some text with words into a QLineEdit (say, "Paste some text with words")

      2) Click somewhere in a space in the middle of the text.

      3) Hold down the Cmd key and press Delete. That is 

      QKeySequence::DeleteCompleteLine. It deletes everything to the start of the line of text, as expected.

      4) Do it again; it deletes the character to the right of the cursor. *** That's a bug ***

       

      The first of these is caused by this code in QWidgetLineControl.cpp, in QWidgetLineControl::processKeyEvent():
      (I'm trying to paste code; how do I do that?)
      {{
        else if (event == QKeySequence::DeleteStartOfWord) {
      if (!isReadOnly())

      { cursorWordBackward(true); del(); }

      }
      }}

      This code tries to set the cursor on the text, but doesn't make sure that it is possible to do correctly. If the cursor is at the start of the line, it should not try to do anything.

      The other example is more complicated because it does not match a pre-existing QKeySequence. But the same is true- no test is done to make sure the cursor is in a proper position before calling del().

      A less important problem is that Control and Cmd are confused- they both do the same thing, which is not expected on a Macintosh. I understand why that is, but it is unexpected.

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            johnweeks John Weeks
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes