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

macOS control-enter to send QContextMenuEvent conflicts with QKeySequence::InsertLineSeparator: no context menus in QTextEdit / TextArea

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P2: Important P2: Important
    • None
    • 6.8, 6.9
    • QPA
    • None
    • macOS

      https://codereview.qt-project.org/c/qt/qtbase/+/597187 added this feature in a way that allows applications to continue handling control-enter for themselves. That's good for backwards compatibility but it turns out that Qt Quick's TextEdit and the QTextEdit widget are handling control-enter already. We have shortcuts defined like this:

      $ grep Separator src/gui/kernel/qplatformtheme.cpp
          {QKeySequence::InsertParagraphSeparator,0,          Qt::Key_Enter,                          KB_All},
          {QKeySequence::InsertParagraphSeparator,0,          Qt::Key_Return,                         KB_All},
          {QKeySequence::InsertLineSeparator,     0,          Qt::META | Qt::Key_Enter,               KB_Mac},
          {QKeySequence::InsertLineSeparator,     0,          Qt::META | Qt::Key_Return,              KB_Mac},
          {QKeySequence::InsertLineSeparator,     0,          Qt::SHIFT | Qt::Key_Enter,              KB_All},
          {QKeySequence::InsertLineSeparator,     0,          Qt::SHIFT | Qt::Key_Return,             KB_All},
          {QKeySequence::InsertLineSeparator,     0,          Qt::META | Qt::Key_O,                   KB_Mac},
      and meta is control on macOS
      

      In QtQuick they are handled like this:

      void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
      ...
      #if QT_CONFIG(shortcut)
            else if (e == QKeySequence::InsertParagraphSeparator) {
      qDebug() << "InsertParagraphSeparator";
              cursor.insertBlock();
              e->accept();
              goto accept;
          } else if (e == QKeySequence::InsertLineSeparator) {
      qDebug() << "InsertLineSeparator";
              cursor.insertText(QString(QChar::LineSeparator));
              e->accept();
              goto accept;
          }
      #endif
      

      https://codereview.qt-project.org/c/qt/qtdeclarative/+/642405 succeeds in adding support for the menu key on Windows but not on macOS so far.

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

            vestbo Tor Arne Vestbø
            srutledg Shawn Rutledge
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes