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

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.3.0
    • Fix Version/s: 5.4.0 RC
    • Component/s: Quick: Controls 1
    • Labels:
      None

      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

              Assignee:
              liaqi Liang Qi
              Reporter:
              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