Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. TextEdit/TextInput/Textfield(QML/QT) to design IP address text box behave unexpected when used with Samsung Android 10 and Samsung number keypad (ImhFormattedNumbersOnly)

TextEdit/TextInput/Textfield(QML/QT) to design IP address text box behave unexpected when used with Samsung Android 10 and Samsung number keypad (ImhFormattedNumbersOnly)

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 2 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chaitanya.GE
    wrote on last edited by Chaitanya.GE
    #1

    HI,

    I have created an IP address text box with requirement of user to enter something like valid IP address 000.000.000.000 with number keypad only.
    I used QML(textfield, textInput, textEdit) with following code

    TextField {
                id: textFieldip
                validator: RegExpValidator {
                    regExp:  /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/
                }
                inputMethodHints: Qt.ImhFormattedNumbersOnly
            }
    

    In Qt widget I tried QLineEdit with following code

    ui->lineEdit->validator(&ipRegexvalid);
        ui->lineEdit->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
    

    **Now issue is with with Samsung android 10 devices (Samsung Android 9 seems working fine) and samsung keyboard's number keypad only
    All text box widges textedit(qml and qt widget both) behave in unexpected way (mischievous) when we try to enter IP address data. Like when we try to enter **

    "10.1" it automatically becoming "101." [Means 1 automatically getting concatenated to previous IP field and "." is moved right side]
    

    Attached samsung number keypad coming in QML/QT application which seems different from Android Native app's number keypad
    https://ddgobkiprc33d.cloudfront.net/a7ef2ac9-136b-4000-a8c0-eececf8b6507.jpg [*Kept images as URL as it's making post unreadable]

    • Tried launching all other keyboard(google, swift) with Qt::ImhFormattedNumbersOnly or ImhDigitsOnly which works fine.

    • Tried launching samsung keyobard in ImhNone and found it working fine.

    • Tried launching samsung number keypad with inputMethodHints: Qt.ImhDigitsOnly|Qt.ImhFormattedNumbersOnly|Qt.ImhNoPredictiveText|Qt.ImhPreferNumbers|Qt.ImhUrlCharactersOnly but that also does not work. {was doubting if ImhNoPredictiveText could affect, also tried disabling autocorrection and prediction off from samsung keyboard}

    • Tied only using normal textField(or other widget) without validator as I had doubt on validator which could restrict but that is not the issue and it behave unexpected wihout validator also.

    To make sure it's not only samsung number keypad issue, created Android Native application and found it is working fine in that app with following implementation. Attached screenshot of how android number keypad comes.
    <EditText
    android:id="@+id/txtName1"
    android:inputType="numberDecimal"
    android:digits="0123456789."
    android:hint="Name3_decimal_digit"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
    https://ddgobkiprc33d.cloudfront.net/2988f6e2-66f0-46f2-b06c-64224865e4e2.jpg

    Does any one else have also faced the same?
    Any solution to this problem? [Tried with input mast, solution is not intuitive and looks ugly]
    Is it the bug from QT/QML 's text editor?

    Any other way to figure out where this issue could be is highly appreciated. Thanks in advance.

    J.HilkJ 1 Reply Last reply
    0
    • C Chaitanya.GE

      HI,

      I have created an IP address text box with requirement of user to enter something like valid IP address 000.000.000.000 with number keypad only.
      I used QML(textfield, textInput, textEdit) with following code

      TextField {
                  id: textFieldip
                  validator: RegExpValidator {
                      regExp:  /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/
                  }
                  inputMethodHints: Qt.ImhFormattedNumbersOnly
              }
      

      In Qt widget I tried QLineEdit with following code

      ui->lineEdit->validator(&ipRegexvalid);
          ui->lineEdit->setInputMethodHints(Qt::ImhFormattedNumbersOnly);
      

      **Now issue is with with Samsung android 10 devices (Samsung Android 9 seems working fine) and samsung keyboard's number keypad only
      All text box widges textedit(qml and qt widget both) behave in unexpected way (mischievous) when we try to enter IP address data. Like when we try to enter **

      "10.1" it automatically becoming "101." [Means 1 automatically getting concatenated to previous IP field and "." is moved right side]
      

      Attached samsung number keypad coming in QML/QT application which seems different from Android Native app's number keypad
      https://ddgobkiprc33d.cloudfront.net/a7ef2ac9-136b-4000-a8c0-eececf8b6507.jpg [*Kept images as URL as it's making post unreadable]

      • Tried launching all other keyboard(google, swift) with Qt::ImhFormattedNumbersOnly or ImhDigitsOnly which works fine.

      • Tried launching samsung keyobard in ImhNone and found it working fine.

      • Tried launching samsung number keypad with inputMethodHints: Qt.ImhDigitsOnly|Qt.ImhFormattedNumbersOnly|Qt.ImhNoPredictiveText|Qt.ImhPreferNumbers|Qt.ImhUrlCharactersOnly but that also does not work. {was doubting if ImhNoPredictiveText could affect, also tried disabling autocorrection and prediction off from samsung keyboard}

      • Tied only using normal textField(or other widget) without validator as I had doubt on validator which could restrict but that is not the issue and it behave unexpected wihout validator also.

      To make sure it's not only samsung number keypad issue, created Android Native application and found it is working fine in that app with following implementation. Attached screenshot of how android number keypad comes.
      <EditText
      android:id="@+id/txtName1"
      android:inputType="numberDecimal"
      android:digits="0123456789."
      android:hint="Name3_decimal_digit"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"/>
      https://ddgobkiprc33d.cloudfront.net/2988f6e2-66f0-46f2-b06c-64224865e4e2.jpg

      Does any one else have also faced the same?
      Any solution to this problem? [Tried with input mast, solution is not intuitive and looks ugly]
      Is it the bug from QT/QML 's text editor?

      Any other way to figure out where this issue could be is highly appreciated. Thanks in advance.

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Chaitanya-GE I think I ran into something similar, and I ended up using an imputmask and enabled overwrite mode on and all values to 0, so it didn't look stupid :D


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chaitanya.GE
        wrote on last edited by Chaitanya.GE
        #3

        @J-Hilk said in TextEdit/TextInput/Textfield(QML/QT) to design IP address text box behave unexpected when used with Samsung Android 10 and Samsung number keypad (ImhFormattedNumbersOnly):

        overwrite

        @J-Hilk Thanks for responding.
        It still does not work, So issue is in combination with text editr widgets(qt/qml) + samsung number keypad(only)
        I tried inputmask also with overridemode (I assume by default it's true)

        inputMask: "000.000.000.000;0" // when we enter 10.2.12.107 -> which looks like 100.200.120.107
        or
        inputMask: "000.000.000.000; " // with regex enabled cant write anything
        or
        inputMask: "000.000.000.000;_"

        It does not look User friendly as user has to drag set cursor to go to next field.

        J.HilkJ 1 Reply Last reply
        0
        • C Chaitanya.GE

          @J-Hilk said in TextEdit/TextInput/Textfield(QML/QT) to design IP address text box behave unexpected when used with Samsung Android 10 and Samsung number keypad (ImhFormattedNumbersOnly):

          overwrite

          @J-Hilk Thanks for responding.
          It still does not work, So issue is in combination with text editr widgets(qt/qml) + samsung number keypad(only)
          I tried inputmask also with overridemode (I assume by default it's true)

          inputMask: "000.000.000.000;0" // when we enter 10.2.12.107 -> which looks like 100.200.120.107
          or
          inputMask: "000.000.000.000; " // with regex enabled cant write anything
          or
          inputMask: "000.000.000.000;_"

          It does not look User friendly as user has to drag set cursor to go to next field.

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          @Chaitanya-GE
          I have something like this:

          Window {
              id: window
          
              width: 120
              height: 60
          
              visible: true
          
              Item {
                  anchors.fill: parent
                  focus: true
          
                  TextInput{
                      anchors.centerIn: parent
                      inputMask: "999.999.999.999"
          
                      overwriteMode: true
          
                      onFocusChanged:{
                          if(focus){
                              text = "000.000.000.000"
                              cursorPosition = 0
          //                    select(0,1)
                          }
                      }
          
                      text: "000.000.000.000"
          
          
                      onEditingFinished:parent.forceActiveFocus()
                      Keys.onReturnPressed: parent.forceActiveFocus()
                      Keys.onEnterPressed: parent.forceActiveFocus()
                  }
              }
          }
          

          you of course have to enter leading 0 as well, but it shouldn't jump prematurely to the next field. At least it doesn't on my test case


          btw, overwriteMode is not on by default


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Chaitanya.GE
            wrote on last edited by
            #5

            @J-Hilk

            Agree that if we prepend 0 then IP address looks fine, But we can't force user to enter 0 in many IP address cases one basic sample is "10.3.4.5".

            Following are still issue:

            1. User can still press "." which again mess up the user input
            2. Issue here is Samsung keyboard always come with ".-" keys together for number keypad.

            I have few more question.
            from QT can we change keyboard layout to finer granularity else than following
            c55400cb-bb71-4f79-af31-00fdea696702-image.png

            instead of following
            67d64193-6d1c-4e1e-9a26-68ddd45188f7-image.png
            If we can populate the following keyboard
            081a91c0-3a41-4c41-b507-5bfa05400fb0-image.png

            It would solve all such problems. Please note i have tried "ImhDigitsOnly" but it does not work.

            J.HilkJ 1 Reply Last reply
            0
            • C Chaitanya.GE

              @J-Hilk

              Agree that if we prepend 0 then IP address looks fine, But we can't force user to enter 0 in many IP address cases one basic sample is "10.3.4.5".

              Following are still issue:

              1. User can still press "." which again mess up the user input
              2. Issue here is Samsung keyboard always come with ".-" keys together for number keypad.

              I have few more question.
              from QT can we change keyboard layout to finer granularity else than following
              c55400cb-bb71-4f79-af31-00fdea696702-image.png

              instead of following
              67d64193-6d1c-4e1e-9a26-68ddd45188f7-image.png
              If we can populate the following keyboard
              081a91c0-3a41-4c41-b507-5bfa05400fb0-image.png

              It would solve all such problems. Please note i have tried "ImhDigitsOnly" but it does not work.

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @Chaitanya-GE I'm afraid you're bound to what the OEM ships with the device :(

              What you can do, if it's a problem, are 2 things, that come to my mind.

              Split your Textinput up into 4 sections (4 TextInputs) that allows you to remove .from the regexpr

              or, create your own popup with buttons that you then forward to your TextInput, that way your independent from the native keyboard!


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Chaitanya.GE
                wrote on last edited by Chaitanya.GE
                #7

                Thanks @J-Hilk.

                Did you consider that OEM shipped samsung keyboard can launch number keypad without combining ". and -"
                Launched from QT/QML
                9942a907-6b9f-42f4-be84-0b6ecc494118-image.png
                VS
                Launched from Android native app
                081d01d5-625c-4f47-bd91-145c945462c5-image.png
                SO i guess QT is launching number keypad with some setting.

                One more finding here is if any keyboard has such combined key, such issue could appear.

                Thanks for your suggestion, we thought of implementing the 1st suggestion and custom component which looks like [ ].[ ].[ ].[ ].
                Second would be not very good solution as we would like to stick with Keyboard's provided number keypad rather than creating self.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved