on 2023 Jul 03 10:44 AM
Hello together,
I have a page with a sap.m.Input field. For this field I want to set the focus out of the controller.
I have tried several approaches. But it works only with the help of setTimeout I gues. Getting the control via this.getView().byId('control') to set the focus does not work reliably.
On a desktop PC and on Android mobile devices this setTimeout approach works. On an iOS device unfortunately not. Sometimes only a small highlighted frame is visible, but not every time on iOS.
Background would be a barcode scanning app. Here is the code that currently works.
onAfterRendering: function () {Are there certain requirements for the focus or does a certain sequence have to be followed for a simple focus() to work out of the controller?
Would it also be possible to set the focus() and hide the soft keyboard initially? Only when the user actively clicks into the input field the keyboard should be shown. So when the focus is set from the controller, then the softkeyboard should be hidden and when the user manually clicks into the field, then the keyboard should be displayed.
Here I have found a work-a-round. Is there a better approach for this?
onTestPress: function () {<br> const oScanField = this.byId("scanField");<br> // https://answers.sap.com/questions/12963714/sapui5-how-to-disable-soft-keyboard-on-android-whe.html<b...; // currently just a workaround for hiding the soft - keyboard on the scanner<br> oScanField.setEditable(false);<br> setTimeout(() => {<br> oScanField.setEditable(true);<br> oScanField.focus();<br> }, 200);<br>}<br>
.
Current UI5 framework are: 1.108.16
Test on Desktop with Browser Edge and Chrome (latest version)
Test on Android with Edge and Chrome (latest version)
Test on iOS with Safari and Chrome (also latest version)
Here the result on the desktop PC as picture:
Here the result on Android as picture:
Here the result on iOS as picture:
Maybe I did something wrong or the implementation needs to be changed from my side. Maybe there is another and more stable approach for my implementation.
Thanks for support
Request clarification before answering.
User | Count |
---|---|
66 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.