Change cursor Focus for Mobile

Halo dear kintone,

I wanna ask, How to set cursor focus when text has been inputted on mobile version ? 

 

For Desktop, i can change the cursor focus after text has been inputted by using document.getElementById(‘id’).focus();

 

But In mobile, i cannot used focus(), even im using document.getElementsByName(‘name’)[0].focus();

 

Thank You

-Best Regards-

Hello Ibnu,

I was looking about this and did some testing on my side, but it seems like the problem depends on the OS of phones.
I was able to do it on the android OS, but seems like it cannot be done on the iOS.
By the way, are using a web browser or the kintone Mobile app?

Hello Yuzo Arai-san,

Im using web browser mobile version for debug, and also using kintone mobile app for android.

But still, focus cursor cannot move to another field after text has been inputted, only work on the create show.

Can you share the code for me, how it can work on android OS ?

 

Thank You for your response,

Best Regards

Hello Ibnu,

This is the code that I used

(function() {
"use strict";
kintone.events.on('mobile.app.record.index.show', function(event) {

var wInput1 = document.createElement('input');
wInput1.id = 'input1';

var wInput2 = document.createElement('input');
wInput2.id = 'input2';
wInput2.onclick = function(){

// alert("onclick : start");

// var nowTime = (new Date()).getTime();
// var endTime = (new Date()).getTime() + 2000; //1000ms
// while(nowTime < endTime) {
// nowTime = (new Date()).getTime();
// }


wInput2.focus();

// alert("onclick : end");
};

kintone.mobile.app.getHeaderSpaceElement().appendChild(wInput1);
kintone.mobile.app.getHeaderSpaceElement().appendChild(wInput2);

setTimeout(function() {
wInput2.onclick();
}, 5000)

});

var events = [
"mobile.app.record.create.show",
"mobile.app.record.edit.show"
];

kintone.events.on(events , function(event) {

var wEle = document.getElementsByClassName('forms-text-gaia')[1];

wEle.touchstart = function(){
wEle.focus();
};

wEle.touchstart();

});
})();