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

On OS X, Cmd+R press must not add "r" to textfields

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.4.0 RC
    • 5.3.0
    • Quick: Controls 1
    • None
    • macOS
    • 933fab137dcaa8bff2a65ca67918f2765875d2cf

    Description

      On OS X, the Cmd-key is the primary shortcut key and the ControlModifier value corresponds to the Command keys on the Macintosh keyboard.

      The problem is, TextEdit, TextField and TextArea suck Control+Something clicks and print the corresponding character into the text instead of executing a shortcut command.

      import QtQuick 2.3
      import QtQuick.Controls 1.2
      
      Rectangle {
          width: 360
          height: 360
      
          function refresh() {
              input1.text = ""
              input2.text = ""
              input3.text = ""
          }
      
          Keys.onPressed: {
              if (event.modifiers & Qt.ControlModifier)
              {
                  if (event.key === Qt.Key_W)
                  {
                      Qt.quit()
                  }
      
                  if (event.key === Qt.Key_R)
                  {
                      refresh()
                      event.accepted = true
                  }
              }
          }
      
          Column {
              anchors.centerIn: parent
      
              TextEdit {
                  id: input1
                  text: "Cmd key test"
              }
      
              TextField {
                  id: input2
                  text: "README"
              }
      
              TextArea {
                  id: input3
                  text: "Cmd+R to refresh text\nCmd+W to close window"
              }
      
              Button {
                  id: button
                  text: "Unfocus all text fields"
                  onClicked: button.forceActiveFocus()
              }
          }
      }
      

      The code works great on Ubuntu using a PC keyboard.

      Attachments

        Issue Links

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

          Activity

            People

              liaqi Liang Qi
              webmaster128 Simon Warta
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes