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

Discrepancy in Quick TextEdit focus handling

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.6.1
    • Quick: Other
    • None
    • x86_64 linux, Sway (tiling Wayland compositor)
    • Linux/Wayland

    Description

      TextEdit focused from code behaves differently to when it is clicked by mouse.

      Minimal example:

      import QtQuick.Window
      Window {
          visible: true
          TextEdit {
              focus: true
              anchors.fill: parent
              text: "Some Content"
              persistentSelection: true
          }
      }
      

      Running with qml, selecting text with keyboard (Shift+Right) and switching to another app (Alt+Tab) will reset selection, meaning persistentSelection plain out doesn't work.

      Click on TextEdit with mouse, then select with keyboard and switch to another app - selection stays.

      (Same behaviour can be observed with standard text editor example)

      I've tracked it down to QQuickTextControlPrivate::cursorIsFocusIndicator (set by mouse click and checked on focus loss), but with all the interconnected logic required fix isn't obvious.

      And affected behavior isn't limited to persistentSelection as I initially stumbled on problem when trying to focus Popup from TextArea, only for it to close immediately (my guess is that selection reset steals focus back to TextArea)

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            versusvoid versusvoid
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes