Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

Commit

Permalink
Merge pull request #104 from omefire/windows-support
Browse files Browse the repository at this point in the history
Adds support for windows platform
  • Loading branch information
tlancina committed Jul 1, 2015
2 parents 3ff1bb7 + 7cf18ba commit 997d4aa
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
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);

0 comments on commit 997d4aa

Please sign in to comment.