Skip to content
This repository was archived by the owner on Apr 2, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Close the keyboard if it is open.
Supported Platforms
-------------------

- iOS, Android, Blackberry 10
- iOS, Android, Blackberry 10, Windows


Keyboard.disableScroll
Expand All @@ -65,18 +65,18 @@ Disable native scrolling, useful if you are using JavaScript to scroll
Supported Platforms
-------------------

- iOS
- iOS, Windows

Keyboard.show
=================

Force keyboard to be shown on Android. This typically helps if autofocus on a text element does not pop up the keyboard automatically
Force keyboard to be shown. This typically helps if autofocus on a text element does not pop up the keyboard automatically

cordova.plugins.Keyboard.show();

Supported Platforms

- Android, Blackberry 10
- Android, Blackberry 10, Windows

native.keyboardshow
=================
Expand All @@ -98,7 +98,7 @@ keyboardHeight: the height of the keyboard in pixels
Supported Platforms
-------------------

- iOS, Android, Blackberry 10
- iOS, Android, Blackberry 10, Windows


native.keyboardhide
Expand All @@ -120,4 +120,4 @@ None
Supported Platforms
-------------------

- iOS, Android, Blackberry 10
- iOS, Android, Blackberry 10, Windows
7 changes: 7 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,11 @@
</config-file>
</platform>

<!-- windows -->
<platform name="windows">
<js-module src="src/windows/KeyboardProxy.js" name="KeyboardProxy">
<runs />
</js-module>
</platform>

</plugin>
38 changes: 38 additions & 0 deletions src/windows/KeyboardProxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

/*global Windows, WinJS, cordova, module, require*/

var inputPane = Windows.UI.ViewManagement.InputPane.getForCurrentView();
var keyboardScrollDisabled = false;

inputPane.addEventListener('hiding', function() {
cordova.fireDocumentEvent('native.keyboardhide');
cordova.plugins.Keyboard.isVisible = false;
});

inputPane.addEventListener('showing', function(e) {
if (keyboardScrollDisabled) {
// this disables automatic scrolling of view contents to show focused control
e.ensuredFocusedElementInView = true;
}
cordova.fireDocumentEvent('native.keyboardshow', { keyboardHeight: e.occludedRect.height });
cordova.plugins.Keyboard.isVisible = true;
});

module.exports.disableScroll = function (win, fail, args) {
var disable = args[0];
keyboardScrollDisabled = disable;
};

module.exports.show = function () {
if (typeof inputPane.tryShow === 'function') {
inputPane.tryShow();
}
};

module.exports.close = function () {
if (typeof inputPane.tryShow === 'function') {
inputPane.tryHide();
}
};

require("cordova/exec/proxy").add("Keyboard", module.exports);