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

keyboard change frame observer #302

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
keyboard change observer
  • Loading branch information
thessler27 committed Nov 7, 2017
commit 64aaea8f63ee414896a9587efc6c18cf633c43ef
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,28 @@ This event fires when the keyboard will be shown or when the keyboard frame resi
alert('Keyboard height is: ' + e.keyboardHeight);
}


Properties
-----------

keyboardHeight: the height of the keyboard in pixels

native.keyboardchange (iOS ONLY)
=================

This event fires when the keyboard will be shown or when the keyboard frame resizes (when switching between keyboards for example)

window.addEventListener('native.keyboardchange', keyboardChangeHandler);

function keyboardChangeHandler(e){
alert('Keyboard height is: ' + e.lang);
}


Properties
-----------

lang: current language of the keyboard. it's a string.

Supported Platforms
-------------------
Expand Down
2 changes: 1 addition & 1 deletion src/ios/IonicKeyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@interface IonicKeyboard : CDVPlugin <UIScrollViewDelegate> {
@protected
id _keyboardShowObserver, _keyboardHideObserver;
id _keyboardShowObserver, _keyboardHideObserver, _keyboardChangeObserver;
IMP wkOriginalImp, uiOriginalImp, nilImp;
Method wkMethod, uiMethod;
}
Expand Down
9 changes: 9 additions & 0 deletions src/ios/IonicKeyboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ - (void)pluginInitialize {
//deprecated
[weakSelf.commandDelegate evalJs:@"cordova.fireWindowEvent('native.hidekeyboard'); "];
}];

_keyboardChangeObserver = [nc addObserverForName:UITextInputCurrentInputModeDidChangeNotification
object:nil queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification* notification){
NSString * primaryLanguage = [UITextInputMode currentInputMode].primaryLanguage;
NSString * jsWithLang = [NSString stringWithFormat:@"cordova.fireWindowEvent('native.keyboardchange', {lang: %@});", primaryLanguage];
[weakSelf.commandDelegate evalJs:jsWithLang];
}];

}

- (BOOL)disableScroll {
Expand Down