Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-32210

Adding multi cursors with Alt-Up/Down doesn't work when Right Alt is configured to switch languages

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • Qt Creator 14.0.0, Qt Creator 15.0.0
    • Editors
    • None
    • Linux/X11

    Description

      I've tracked down the issue to commit bb08762123283321f87334daf19a000e8b0d46cf. It had the following as part of it:

      -    uint searchkey = (e->modifiers() | e->key())
      -                     & ~(Qt::KeypadModifier
      -                         | Qt::GroupSwitchModifier
      -                         | Qt::AltModifier
      -                         | Qt::ShiftModifier);
      +    uint searchkey = (e->modifiers() | e->key()) & ~(filterModifiers | Qt::AltModifier); 

      Notice how this removes GroupSwitchModifier from filters. Turns out, that was important, since that modifier is somehow present there when Right Alt is used to switch languages, at least as of Qt 6.8.1 (to clarify, while Right Alt switches languages, it is Left Alt which is used with Up/Down to place cursors - I have no idea why Right Alt being configured to switch languages affects Left Alt as well, but apparently it does).

      The patch for this issue, for version 15, is to add GroupSwitchModifier back to the list of filters:

       

      diff --git a/src/libs/utils/multitextcursor.cpp b/src/libs/utils/multitextcursor.cpp
      index a02bfebea53..e5891cfbc01 100644
      --- a/src/libs/utils/multitextcursor.cpp
      +++ b/src/libs/utils/multitextcursor.cpp
      @@ -339,7 +339,7 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
       bool MultiTextCursor::multiCursorEvent(
           QKeyEvent *e, QKeySequence::StandardKey matchKey, Qt::KeyboardModifiers filterModifiers)
       {
      -    filterModifiers |= (Utils::HostOsInfo::isMacHost() ? Qt::KeypadModifier : Qt::AltModifier);
      +    filterModifiers |= (Utils::HostOsInfo::isMacHost() ? Qt::KeypadModifier : Qt::GroupSwitchModifier | Qt::AltModifier);
           uint searchkey = (e->modifiers() | e->key()) & ~filterModifiers;
       
           const QList<QKeySequence> bindings = QKeySequence::keyBindings(matchKey);

       

       

      I've tested it and it fixed the issue. The versions affected are 14 and 15.

       

       

       

      Attachments

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

        Activity

          People

            davschul David Schulz
            dragonroot Konstantin Isakov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes