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

TapHandler on TextField (for showing right click context menu) stops working in Qt6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 6.4.1, 6.5.0 Beta1
    • 6.2.2, 6.3.0 Alpha
    • Quick: Controls 2
    • None
    • macOS
    • 0f85202699 (qt/qtdeclarative/dev) 25ab62cce5 (qt/qtdeclarative/6.4) 25ab62cce5 (qt/tqtc-qtdeclarative/6.4) 0f85202699 (qt/tqtc-qtdeclarative/dev) 25ab62cce5 (qt/qtdeclarative/6.4.1)

    Description

      The following example prints "TAP" on right clicks until Qt 5.15.2.

      With Qt 6.2 / 6.3 this stops working (haven't tried Qt 6.0/6.1).

      Motivation for intercepting a right click is to show a desktop text context menu (Cut/Copy/Paste) which (unfortunately) is still not available out-of-the box with TextField/TextArea.

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Window 2.15
      
      Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
      
        TextField {
          anchors.centerIn: parent
          width: 200
          text: "Hello"
          selectByMouse: true
      
          TapHandler {
            acceptedButtons: Qt.RightButton
            acceptedDevices: PointerDevice.Mouse
            onTapped: {
              console.log("TAP")
            }
          }
        }
      }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-99887
          # Subject Branch Project Status CR V

          Activity

            People

              srutledg Shawn Rutledge
              njeisecke Nils Jeisecke
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There is 1 open Gerrit change