TextEdit/TextInput/Textfield(QML/QT) to design IP address text box behave unexpected when used with Samsung Android 10 and Samsung number keypad (ImhFormattedNumbersOnly)
-
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 codeTextField { 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.jpgDoes 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.
-
-
@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
-
@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.
-
@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
-
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:
- User can still press "." which again mess up the user input
- 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
instead of following
If we can populate the following keyboard
It would solve all such problems. Please note i have tried "ImhDigitsOnly" but it does not work.
-
@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 regexpror, create your own popup with buttons that you then forward to your TextInput, that way your independent from the native keyboard!
-
Thanks @J-Hilk.
Did you consider that OEM shipped samsung keyboard can launch number keypad without combining ". and -"
Launched from QT/QML
VS
Launched from Android native app
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.