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

Commit 997d4aa

Browse files
committed
Merge pull request #104 from omefire/windows-support
Adds support for windows platform
2 parents 3ff1bb7 + 7cf18ba commit 997d4aa

File tree

3 files changed

+51
-6
lines changed

3 files changed

+51
-6
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Close the keyboard if it is open.
5151
Supported Platforms
5252
-------------------
5353

54-
- iOS, Android, Blackberry 10
54+
- iOS, Android, Blackberry 10, Windows
5555

5656

5757
Keyboard.disableScroll
@@ -65,18 +65,18 @@ Disable native scrolling, useful if you are using JavaScript to scroll
6565
Supported Platforms
6666
-------------------
6767

68-
- iOS
68+
- iOS, Windows
6969

7070
Keyboard.show
7171
=================
7272

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

7575
cordova.plugins.Keyboard.show();
7676

7777
Supported Platforms
7878

79-
- Android, Blackberry 10
79+
- Android, Blackberry 10, Windows
8080

8181
native.keyboardshow
8282
=================
@@ -98,7 +98,7 @@ keyboardHeight: the height of the keyboard in pixels
9898
Supported Platforms
9999
-------------------
100100

101-
- iOS, Android, Blackberry 10
101+
- iOS, Android, Blackberry 10, Windows
102102

103103

104104
native.keyboardhide
@@ -120,4 +120,4 @@ None
120120
Supported Platforms
121121
-------------------
122122

123-
- iOS, Android, Blackberry 10
123+
- iOS, Android, Blackberry 10, Windows

plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,11 @@
5252
</config-file>
5353
</platform>
5454

55+
<!-- windows -->
56+
<platform name="windows">
57+
<js-module src="src/windows/KeyboardProxy.js" name="KeyboardProxy">
58+
<runs />
59+
</js-module>
60+
</platform>
61+
5562
</plugin>

src/windows/KeyboardProxy.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
/*global Windows, WinJS, cordova, module, require*/
3+
4+
var inputPane = Windows.UI.ViewManagement.InputPane.getForCurrentView();
5+
var keyboardScrollDisabled = false;
6+
7+
inputPane.addEventListener('hiding', function() {
8+
cordova.fireDocumentEvent('native.keyboardhide');
9+
cordova.plugins.Keyboard.isVisible = false;
10+
});
11+
12+
inputPane.addEventListener('showing', function(e) {
13+
if (keyboardScrollDisabled) {
14+
// this disables automatic scrolling of view contents to show focused control
15+
e.ensuredFocusedElementInView = true;
16+
}
17+
cordova.fireDocumentEvent('native.keyboardshow', { keyboardHeight: e.occludedRect.height });
18+
cordova.plugins.Keyboard.isVisible = true;
19+
});
20+
21+
module.exports.disableScroll = function (win, fail, args) {
22+
var disable = args[0];
23+
keyboardScrollDisabled = disable;
24+
};
25+
26+
module.exports.show = function () {
27+
if (typeof inputPane.tryShow === 'function') {
28+
inputPane.tryShow();
29+
}
30+
};
31+
32+
module.exports.close = function () {
33+
if (typeof inputPane.tryShow === 'function') {
34+
inputPane.tryHide();
35+
}
36+
};
37+
38+
require("cordova/exec/proxy").add("Keyboard", module.exports);

0 commit comments

Comments
 (0)