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

QML Shortcut: improve documentation and use cases

XMLWordPrintable

      QML Shortcut documentation is short...

      For example, it doesn't explain we can create several shortcuts with the same sequence and enable one, like for a radio button.

      Basic example to test this feature:

          Shortcut {
              id: shortcut1
              sequence: StandardKey.MoveToPreviousPage
              enabled: true
              onActivated: {
                  console.info('shortcut1')
                  enabled = false
                  shortcut2.enabled = true
              }
          }
      
          Shortcut {
              id: shortcut2
              sequence: StandardKey.MoveToPreviousPage
              enabled: false
              onActivated: {
                  console.info('shortcut2')
                  enabled = false
                  shortcut1.enabled = true
              }
          }
      

      To explore use cases, we can give a look to the sophisticated Emacs key maps:

      Which implements modes and an active keymap, which is a merge of the global and locales keymaps.

      A basic use case is to share a shortcut for several actions depending on the current application mode. Then the question is how we should implement the mapping ?

      Further info

      QML Shortcut is implemented in

      • qtdeclarative/src/quick/util/qquickshortcut.cpp
      • qtbase/src/gui/kernel/qshortcutmap.cpp

      Shorcuts are stored in QGuiApplication

      QGuiApplicationPrivate *pApp = QGuiApplicationPrivate::instance();
      shortcut.id = pApp->shortcutMap.addShortcut(this, shortcut.keySequence, context, *ctxMatcher());
      

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            fabricesalvaire fabrice salvaire
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes