cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 - How to disable soft keyboard on android when focus is set on input field

emil33
Participant
2,634

I have a SAPUI5 scan web app which sets focus on an input field every time you click anywhere on the screen or leave the menu. This makes sure it is ready to display the scanned value in the input field.

The problem is that when the focus is set to the input field, the soft keyboard is displayed. I only want the soft keyboard to be displayed when the user specifically clicks on the input field.

My current solution is to disable the input, focus on the input and then enable the input field:

scannedInput.setEditable(false);
scannedInput.setEditable(false);scannedInput.setEditable(false);scannedInput.focus();
setTimeout(function(){
    scannedInput.setEditable(true);},50);

The problem with this solution is that the screen flickers when this happens, as the keyboard appears and disappears.

Does anyone know a better solution?

Thanks

View Entire Topic

This is now an old question, but I am posting my solution in case it helps anyone.

I defined a custom control that is an extension of the standard sap.m.Input, where I add a property for the inputmode, which is then added as an attribute during rendering of the control:

sap.ui.define(
['sap/m/Input'],
function (Input) {
return Input.extend("co.example.control.Input", {
metadata: {
properties: {
'inputmode': {type: 'string', defaultValue: 'none'}
}
},
renderer: {
writeInnerAttributes: function (oRm, oInput) {
sap.m.InputRenderer.writeInnerAttributes.apply(this, arguments);
oRm.attr('inputmode', oInput.getInputmode())
}
}
})
}
)

Here is an example implementation:

<ei:ExtendedInput inputmode="none"
change="onBarcodeScan"
value="{/ScannedBarcode}"/>

You can, of course, using a model binding if you need to make the value dynamic, which I had to, as I explain in my slightly more detailed answer here.