0

I am trying to open the iOS keyboard whenever the user long clicks on a button. However, right now, only the normal click is working.

Clarification: I KNOW I need to use a proxy textfield. It is also WORKING for normal clicks. I just need a way to handle when the user presses a button for a longer time .

I assume it has to do with the events allowed to trigger a keyboard opening. It only seems to work when the "touchend" event is triggered, not when it is done from within the "touchstart" event with setTimeout. Is there any workaround to this limitation?

https://jsfiddle.net/qu2nej0r/12/

let c = new fabric.Canvas(document.getElementById('cvs'));

$('#t').longpress(_ => {

  let i = new fabric.IText(_.type);
  c.add(i);
  c.setActiveObject(i);
  c.renderAll();
  i.enterEditing();
}, _ => {
  let i = new fabric.IText(_.type, {
    left: 40,
    top: 40
  });
  c.add(i);
  c.setActiveObject(i);
  c.renderAll();
  i.enterEditing();
});
Zahlii
  • 818
  • 1
  • 7
  • 17
  • Does this give any hints https://stackoverflow.com/questions/4609765/manually-triggering-the-iphone-ipad-ipod-keyboard-from-javascript – mplungjan Apr 30 '18 at 16:12
  • I have a working solution for a single click involving a proxy hidden element. I need one working when I set a timeout within a click callback, to make the keyboard appear on long clicks – Zahlii Apr 30 '18 at 16:18

1 Answers1

0

ok i can provide you solution in jQuery Javascript Code you can then convert it easily to ios javascript

var time = 0

$('#mybutton').click(function(){
    setInterval(function(){
        time += 1;
        if (time == 5) {
            openkeyboard()
        }
    }, 1000)  // 1000 millisecond which is 1 second
})

function openkeyboard() {
    // some code here
}
Gaurav Bharti
  • 1,065
  • 1
  • 14
  • 22
Prince Hamza
  • 1,090
  • 12
  • 21
  • There is next to NOTHING useful here. Please do not answer with joke answers – mplungjan Apr 30 '18 at 16:17
  • 1
    I assume without testing that this won't work in iOS due to the fact that setInterval is used around it. I know how to detect long presses, but I can't open they keyboard once I detected it. – Zahlii Apr 30 '18 at 16:19
  • The setInterval is not taking into account the touchstart and -end nor how to actually open the keyboard. - I do not believe this code solves anything – mplungjan Apr 30 '18 at 16:20