summaryrefslogtreecommitdiff
path: root/platform/iphone/gl_view.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/iphone/gl_view.mm')
-rw-r--r--platform/iphone/gl_view.mm40
1 files changed, 40 insertions, 0 deletions
diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm
index 3e206c3a2c..02da706cc5 100644
--- a/platform/iphone/gl_view.mm
+++ b/platform/iphone/gl_view.mm
@@ -63,6 +63,7 @@ void _pause_video();
void _focus_out_video();
void _unpause_video();
void _stop_video();
+CGFloat _points_to_pixels(CGFloat);
void _show_keyboard(String p_existing) {
keyboard_text = p_existing;
@@ -174,6 +175,19 @@ void _stop_video() {
video_playing = false;
}
+CGFloat _points_to_pixels(CGFloat points) {
+ float pixelPerInch;
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ pixelPerInch = 132;
+ } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
+ pixelPerInch = 163;
+ } else {
+ pixelPerInch = 160;
+ }
+ CGFloat pointsPerInch = 72.0;
+ return (points / pointsPerInch * pixelPerInch);
+}
+
@implementation GLView
@synthesize animationInterval;
@@ -537,6 +551,20 @@ static void clear_touches() {
[self resignFirstResponder];
};
+- (void)keyboardOnScreen:(NSNotification *)notification {
+ NSDictionary *info = notification.userInfo;
+ NSValue *value = info[UIKeyboardFrameEndUserInfoKey];
+
+ CGRect rawFrame = [value CGRectValue];
+ CGRect keyboardFrame = [self convertRect:rawFrame fromView:nil];
+
+ OSIPhone::get_singleton()->set_virtual_keyboard_height(_points_to_pixels(keyboardFrame.size.height));
+}
+
+- (void)keyboardHidden:(NSNotification *)notification {
+ OSIPhone::get_singleton()->set_virtual_keyboard_height(0);
+}
+
- (void)deleteBackward {
if (keyboard_text.length())
keyboard_text.erase(keyboard_text.length() - 1, 1);
@@ -606,6 +634,18 @@ static void clear_touches() {
name:AVAudioSessionRouteChangeNotification
object:nil];
+ printf("******** adding observer for keyboard show/hide\n");
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(keyboardOnScreen:)
+ name:UIKeyboardDidShowNotification
+ object:nil];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
+ selector:@selector(keyboardHidden:)
+ name:UIKeyboardDidHideNotification
+ object:nil];
+
//self.autoresizesSubviews = YES;
//[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];