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

Discrepancy in Quick TextEdit focus handling

XMLWordPrintable

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

      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)

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

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

              Created:
              Updated:

                There are no open Gerrit changes