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

ensureCursorVisible() doesn't ensure the cursor is visible

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.8
    • GUI: Text handling
    • None
    • macOS

    Description

      Make a QTextEdit with several pages worth of text in it, so it isn't all visible. Select a full line of text, including the endline at the end, with a triple-click or a drag; be sure the endline is part of the selection. Scroll so the visible area is below the selected text. Now do a ensureCursorVisible(). The view will scroll so that the beginning of the line after the selection is at the top of the view; the cursor is not visible at all. This is the main point of this bug.

      Conversely, if you scroll so the visible area is above the selected text and then do ensureCursorVisible(), the scrolling will put the beginning of the line after the selection at the bottom of the view, so the cursor will not only be visible, but will be one line above where it would normally be positioned. This is a very minor secondary bug.

      Overall, I'd say the behavior of ensureCursorVisible() is not very helpful anyway; from the user's perspective, it unpredictably puts the cursor at either the very top or the very bottom of the visible area, and the user can't really guess which, so they then have to do a little visual hunt for where the cursor has ended up. This is particularly annoying if the cursor is just an insertion point. I'd suggest two improvements. One, put the cursor at the vertical center of the view, not the top or bottom, when possible. Two, visually flash the cursor so it's more visible. (Note that macOS does this when you do Jump To Selection in, e.g., TextEdit, but Qt does not, so doing this on macOS, at least, would be a matter of conformance to the platform standard.) This is an enhancement request, related to the bug being reported here. :->

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            bhaller Ben Haller
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes