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

TextField inside Rectangle with Keys.onPressed doesn't receive keyboard input

    XMLWordPrintable

Details

    • qtdeclarative#release: 8da17239ed4a68270c74f6a5e5ca04d82d99b547

    Description

      The following code worked on this mac in 5.2.1 and iOS. It works on iOS in 5.3 but will not receive text input on the mac. If I comment out event.accepted=true the textField receives keyboard input again properly

      Rectangle {
          id: root
      
          anchors.fill: parent
          color: "#AA000000"
      
          Rectangle {
              id: contentHolder
              anchors.top: parent.top
              anchors.left: parent.left
              height: parent.height
              width: parent.width
              color: "transparent"
      
              Rectangle {
                  id: content
                  property real spacing: 6
                  property real outerSpacing: 12
                  property real buttonsRowImplicitWidth: Screen.pixelDensity * 50
                  height: childrenRect.height
                  width: Screen.primaryOrientation==Qt.PortraitOrientation?root.width * 0.8 : root.width * 0.5
      //            color: backgroundColor
      //            focus: root.visible
                  anchors.centerIn: parent
                  Keys.onPressed: {
                      event.accepted = true
                      if (event.modifiers === Qt.ControlModifier)
                          switch (event.key) {
                          case Qt.Key_A:
                              textInputControl.selectAll()
                              break
                          case Qt.Key_C:
                              textInputControl.copy()
                              break
                      } else switch (event.key) {
                          case Qt.Key_Escape:
                          case Qt.Key_Back:
                              button2Clicked()
                              break
                          case Qt.Key_Enter:
                          case Qt.Key_Return:
                              button1Clicked()
                              break
                      }
                  }
      
                  TextField {
                      id: textInputControl
                      anchors {
                          left: parent.left
                          right: parent.right
                          top:parent.top
      //                    margins: content.outerSpacing
                      }
      
                      //work around for bug https://bugreports.qt-project.org/browse/QTBUG-35689
                      inputMethodHints: Qt.ImhNoPredictiveText
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            jp36 James Pettitt
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes