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

Accept ShortcutOverride event for all keys which are handled by widget

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • Some future release
    • 4.3.0
    • Other
    • None

    Description

      A case:
      My app have defined Escape shortcut for some action. When I open combobox and press Escape my combobox is not closed but application's action is invoked instead.
      The solution:
      Accept ShortcutOverride event for Escape key inside combobox. In this way shortcut will not be triggered and combobox will receive its KeyPress event with Escape key.

      This is general problem. One could go through all the widgets and fix similar issues.

      The patch for combobox and itemdelegate regarding Escape shortcut:

      ==== //depot/qt/4.3/src/gui/itemviews/qitemdelegate.cpp#5 - /home/jkobus/dev/qt-4.3/src/gui/itemviews/qitemdelegate.cpp ====
      @@ -1155,6 +1155,11 @@
      emit commitData(editor);
      emit closeEditor(editor, NoHint);
      }
      + } else if (event->type() == QEvent::ShortcutOverride) {
      + if (static_cast<QKeyEvent*>(event)->key() == Qt::Key_Escape)

      { + event->accept(); + return false; + }

      }
      return false;
      }
      ==== //depot/qt/4.3/src/gui/widgets/qcombobox.cpp#15 - /home/jkobus/dev/qt-4.3/src/gui/widgets/qcombobox.cpp ====
      @@ -544,6 +544,13 @@
      break;
      }
      break;
      + case QEvent::ShortcutOverride: {
      + if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape)

      { + e->accept(); + return false; + }

      + break;
      + }
      case QEvent::MouseMove: {
      if (isVisible()) {
      QMouseEvent *m = static_cast<QMouseEvent *>(e);

      Attachments

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

        Activity

          People

            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            jkobus Jarek Kobus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes