Permalink
Browse files

moved the keyboard event methods to a better place in the file

  • Loading branch information...
1 parent c8ddb71 commit 2dba9ada625a7581432c9f515348759d86a4e8c6 @jantuitman committed Sep 14, 2011
Showing with 36 additions and 30 deletions.
  1. +36 −30 ios_wrapper/ios_wrapper/ios_wrapperViewController.m
View
66 ios_wrapper/ios_wrapper/ios_wrapperViewController.m
@@ -51,36 +51,6 @@ - (void)viewDidLoad
[webView loadRequest:requestObj];
}
-- (void) keyboardWillShow: (NSNotification*) item {
- NSDictionary* info = [item userInfo];
- CGRect kbRect = (CGRect) [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
- CGRect screenCoords = [[webView window] convertRect:kbRect fromWindow: nil];
- CGRect viewCoords= [webView convertRect:screenCoords fromView:nil];
- NSLog(@"Keyboard will show at : %f,%f size %f,%f ",viewCoords.origin.x,viewCoords.origin.y,viewCoords.size.width,viewCoords.size.height);
- NSDictionary* d = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithFloat: viewCoords.origin.x], @"x",
- [NSNumber numberWithFloat: viewCoords.origin.y], @"y",
- [NSNumber numberWithFloat: viewCoords.size.width], @"width",
- [NSNumber numberWithFloat: viewCoords.size.height], @"height",
- nil];
- [dispatcher postEvent:@"ios.keyboard.show" withData:d forView: webView];
-
-}
-- (void) keyboardWillHide: (NSNotification*) item {
- NSDictionary* info = [item userInfo];
- CGRect kbRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue ];
- CGRect screenCoords = [[webView window] convertRect:kbRect fromWindow: nil];
- CGRect viewCoords= [webView convertRect:screenCoords fromView:nil];
- NSLog(@"Keyboard will hide from : %f,%f size %f,%f ",viewCoords.origin.x,viewCoords.origin.y,viewCoords.size.width,viewCoords.size.height);
- NSDictionary* d = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithFloat: viewCoords.origin.x], @"x",
- [NSNumber numberWithFloat: viewCoords.origin.y], @"y",
- [NSNumber numberWithFloat: viewCoords.size.width], @"width",
- [NSNumber numberWithFloat: viewCoords.size.height], @"height",
- nil];
- [dispatcher postEvent:@"ios.keyboard.hide" withData:d forView: webView];
-
-}
- (void)viewDidUnload
{
@@ -120,6 +90,42 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
}
}
+/** keyboard events **/
+
+- (void) keyboardWillShow: (NSNotification*) item {
+ NSDictionary* info = [item userInfo];
+ CGRect kbRect = (CGRect) [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
+ CGRect screenCoords = [[webView window] convertRect:kbRect fromWindow: nil];
+ CGRect viewCoords= [webView convertRect:screenCoords fromView:nil];
+ NSLog(@"Keyboard will show at : %f,%f size %f,%f ",viewCoords.origin.x,viewCoords.origin.y,viewCoords.size.width,viewCoords.size.height);
+ NSDictionary* d = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithFloat: viewCoords.origin.x], @"x",
+ [NSNumber numberWithFloat: viewCoords.origin.y], @"y",
+ [NSNumber numberWithFloat: viewCoords.size.width], @"width",
+ [NSNumber numberWithFloat: viewCoords.size.height], @"height",
+ nil];
+ [dispatcher postEvent:@"ios.keyboard.show" withData:d forView: webView];
+
+}
+- (void) keyboardWillHide: (NSNotification*) item {
+ NSDictionary* info = [item userInfo];
+ CGRect kbRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue ];
+ CGRect screenCoords = [[webView window] convertRect:kbRect fromWindow: nil];
+ CGRect viewCoords= [webView convertRect:screenCoords fromView:nil];
+ NSLog(@"Keyboard will hide from : %f,%f size %f,%f ",viewCoords.origin.x,viewCoords.origin.y,viewCoords.size.width,viewCoords.size.height);
+ NSDictionary* d = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithFloat: viewCoords.origin.x], @"x",
+ [NSNumber numberWithFloat: viewCoords.origin.y], @"y",
+ [NSNumber numberWithFloat: viewCoords.size.width], @"width",
+ [NSNumber numberWithFloat: viewCoords.size.height], @"height",
+ nil];
+ [dispatcher postEvent:@"ios.keyboard.hide" withData:d forView: webView];
+
+}
+
+
+
+
/** delegate methods for webview */
- (void)webViewDidStartLoad:(UIWebView *)theWebView {
NSLog(@"loading stuf...");

0 comments on commit 2dba9ad

Please sign in to comment.