I'm developing a cordova / angular hybrid app. I'm trying to disable the ability for the user to scroll whilst the keyboard is open.
The cordova keyboard plugin from ionic ionic-plugin-keyboard provides two events, one for when the keyboard opens and another for when it closes. The event for when the keyboard closes does not fire, ever.
In an angular run script (app.run(function...) I am have the following snippet:
document.addEventListener('native.keyboardshow', keyboardShowHandler);
function keyboardShowHandler(e){
alert("keyboard open"); //This never fires!
$cordovaKeyboard.disableScroll(true);
}
window.addEventListener('native.keyboardhide', keyboardHideHandler);
function keyboardHideHandler(e){
alert("keyboard closed"); //This fires as expected.
$cordovaKeyboard.disableScroll(false);
}
The event handler for 'native.keyboardshow' never fires, the 'native.keyboardhide' event fires consistently, as expected.
After some googling I came across a post saying that the App can't be run in Fullscreen mode. I added the following to my confix.xml:
<preference name="Fullscreen" value="false" />
This I believe is the default value anyway, it made not difference, neither did setting the value to true.
Has anyone come across this? I'm using Cordova 6.0.0
You should register your listener to the window
object as you already did with your 'native.keyboardhide'
event:
window.addEventListener('native.keyboardshow', keyboardShowHandler);
function keyboardShowHandler(e){
alert("keyboard open"); //This never fires!
$cordovaKeyboard.disableScroll(true);
}