2

Just starting to look at cocoonjs and tried the canvas demo from their tutorial using the launcher app.. I was wondering though is there a way to bring up the soft keyboard on mobile when opening an app (without a text input on screen, or perhaps with one that is hidden)?

gratz
  • 1,506
  • 3
  • 16
  • 34

1 Answers1

2

If you are using the newest launcher and lib, you should be able to do that via this code:

Cocoon.Dialog.showKeyboard({ 
   type : Cocoon.Dialog.keyboardType.TEXT,
},{
   insertText: function(inserted) { text+= inserted; console.log(text);},
   deleteBackward: function() {text = text.slice(0, text.length -1); console.log(text);},
   done : function(){ console.log("user clicked done key") },
   cancel : function(){ console.log("user dismissed keyboard") }
});

You can then hide the keyboard via this code:

Cocoon.Dialog.dismissKeyboard();

If you get an error that "deleteBackward" is undefined, go to the cocoon.js file search for this line:

[params, insertCallback, deleteBackward, doneCallback, cancelCallback], true);

and replace it with this one:

[params, insertCallback, deleteCallback, doneCallback, cancelCallback], true);
Scdev
  • 373
  • 2
  • 13
  • Do you know if it's also possible to clear the inserted text? As in the string that builds up in the keyboard as you're typing before pressing done... or alternatively invoking the done without the user having to press it? – gratz Nov 27 '14 at 16:01
  • Mhhh, I did not have a deep look into it but I do not think this is possible atm :/ – Scdev Nov 29 '14 at 01:54
  • Have you guys tested it on ios 10.2 cocoon v 2.0.0 ? It ain't working for me. – Yordan Kanchelov Jan 12 '17 at 16:02