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

Need to be able to disable autoscroll of root view on iOS when input focus raises keyboard

    XMLWordPrintable

Details

    • iOS/tvOS/watchOS

    Description

      On iOS, the code in qtbase/src/plugins/platforms/ios/qiosinputcontext.mm will auto scroll the root view such that the input text field that is focused is not obscured by the keyboard. This works pretty well in simple applications but causes difficulties when you want more sophisticated handling. For instance:

      1. If you want to anchor a QML toolbar to the top of the keyboard while it is open.
      2. If you want to use the Flickable bottomMargin to keep a background showing behind the translucent keyboard instead of black.
      3. If you want to use the Flickable bottomMargin so you can allow the content area to scroll fully and/or programmatically bring any different text field into view.

      In QML, I would like to just change the Flickable bottomMargin when the keyboard comes up using the information in Qt.inputMethod.keyboardRectangle and am willing to position textfields on my own within the Flickable. However, because the autoscrolling behavior translates the entire root view, I would have to do tricky translations to undo the effects of the root view translation so that the resulting Flickable content area actually lands in the viewable area above the keyboard. On top of that, the amount of translation actually happening is hidden within this class. I think I can back it out by seeing where the bottom of the keyboard is compared to the bottom of my QML root view and also set Flickable topMargin, but that's ugly and seems an error prone way to try and negate the effects of the y translation.

      Ideally, I would like some setting on QInputMethod that would let me disable this behavior so I can manage it myself.

      In the meantime, can anybody suggest a workaround? It doesn't seem to be possible to modify this behavior on the C++ side without doing a custom build of Qt which I would really like to avoid.

      I might be able to throw a category on QIOSKeyboardListener and monkey patch the methods calling scrollToCursor() but that seems pretty ugly and fragile.

      Any suggested workarounds that are simple and likely to work?

      Attachments

        Issue Links

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

          Activity

            People

              richard Richard Moe Gustavsen
              dhess David Hess
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes