You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/03/18 22:06:07 UTC
git commit: CB-5767 - Keyboard will/did hide/show events should be
passed to JavaScript
Repository: cordova-plugins
Updated Branches:
refs/heads/master 5fe04d7ac -> 80561e433
CB-5767 - Keyboard will/did hide/show events should be passed to JavaScript
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/80561e43
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/80561e43
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/80561e43
Branch: refs/heads/master
Commit: 80561e433ada6cd7f30dfce01fe6c8034cc124f2
Parents: 5fe04d7
Author: Andrey Kurdyumov <ka...@gmail.com>
Authored: Sun Mar 16 19:17:36 2014 +0600
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Mar 18 14:03:38 2014 -0700
----------------------------------------------------------------------
keyboard/README.md | 89 ++++++++++++++++++++++++++++++++++++-
keyboard/src/ios/CDVKeyboard.h | 2 +-
keyboard/src/ios/CDVKeyboard.m | 17 ++++++-
3 files changed, 104 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/80561e43/keyboard/README.md
----------------------------------------------------------------------
diff --git a/keyboard/README.md b/keyboard/README.md
index 763c8ea..70abfdd 100644
--- a/keyboard/README.md
+++ b/keyboard/README.md
@@ -21,6 +21,14 @@ Properties
- Keyboard.isVisible
+Events
+--------
+
+- Keyboard.onshow
+- Keyboard.onhide
+- Keyboard.onshowing
+- Keyboard.onhiding
+
Permissions
-----------
@@ -124,4 +132,83 @@ Supported Platforms
- iOS
-
\ No newline at end of file
+Keyboard.onshow
+=================
+
+If defined, this function fired when keyboard fully shown.
+
+ Keyboard.onshow = function () {
+ // Describe your logic which will be run each time keyboard is shown.
+ }
+
+Description
+-----------
+
+Attach handler to this event to be able to receive notification when keyboard is shown.
+
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Keyboard.onhide
+=================
+
+If defined, this function fired when keyboard fully closed.
+
+ Keyboard.onhide = function () {
+ // Describe your logic which will be run each time keyboard is closed.
+ }
+
+Description
+-----------
+
+Attach handler to this event to be able to receive notification when keyboard is closed.
+
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Keyboard.onshowing
+=================
+
+If defined, this function fired before keyboard will be shown.
+
+ Keyboard.onshowing = function () {
+ // Describe your logic which will be run each time when keyboard is about to be shown.
+ }
+
+Description
+-----------
+
+Attach handler to this event to be able to receive notification when keyboard is about to be shown on the screen.
+
+
+Supported Platforms
+-------------------
+
+- iOS
+
+Keyboard.onhiding
+=================
+
+If defined, this function fired when keyboard fully closed.
+
+ Keyboard.onhiding = function () {
+ // Describe your logic which will be run each time when keyboard is about to be closed.
+ }
+
+Description
+-----------
+
+Attach handler to this event to be able to receive notification when keyboard is about to be closed.
+
+
+Supported Platforms
+-------------------
+
+- iOS
+
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/80561e43/keyboard/src/ios/CDVKeyboard.h
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.h b/keyboard/src/ios/CDVKeyboard.h
index 9898f7a..6049dbe 100644
--- a/keyboard/src/ios/CDVKeyboard.h
+++ b/keyboard/src/ios/CDVKeyboard.h
@@ -27,7 +27,7 @@
@protected
BOOL _hideFormAccessoryBar;
@protected
- id _keyboardShowObserver, _keyboardHideObserver;
+ id _keyboardShowObserver, _keyboardHideObserver, _keyboardWillShowObserver, _keyboardWillHideObserver;
@protected
id _hideFormAccessoryBarKeyboardShowObserver, _hideFormAccessoryBarKeyboardHideObserver;
@protected
http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/80561e43/keyboard/src/ios/CDVKeyboard.m
----------------------------------------------------------------------
diff --git a/keyboard/src/ios/CDVKeyboard.m b/keyboard/src/ios/CDVKeyboard.m
index d3b823a..2aa92b4 100644
--- a/keyboard/src/ios/CDVKeyboard.m
+++ b/keyboard/src/ios/CDVKeyboard.m
@@ -69,16 +69,29 @@
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification* notification) {
- [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = true;"];
+ [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = true;if (Keyboard.onshow) Keyboard.onshow();"];
weakSelf.keyboardIsVisible = YES;
}];
_keyboardHideObserver = [nc addObserverForName:UIKeyboardDidHideNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification* notification) {
- [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = false;"];
+ [weakSelf.commandDelegate evalJs:@"Keyboard.isVisible = false;if (Keyboard.onhide) Keyboard.onhide();"];
weakSelf.keyboardIsVisible = NO;
}];
+
+ _keyboardWillShowObserver = [nc addObserverForName:UIKeyboardWillShowNotification
+ object:nil
+ queue:[NSOperationQueue mainQueue]
+ usingBlock:^(NSNotification* notification) {
+ [weakSelf.commandDelegate evalJs:@"if (Keyboard.onshowing) Keyboard.onshowing();"];
+ }];
+ _keyboardWillHideObserver = [nc addObserverForName:UIKeyboardWillHideNotification
+ object:nil
+ queue:[NSOperationQueue mainQueue]
+ usingBlock:^(NSNotification* notification) {
+ [weakSelf.commandDelegate evalJs:@"if (Keyboard.onhiding) Keyboard.onhiding();"];
+ }];
}
// //////////////////////////////////////////////////