commit
43e08997f1
@ -57,7 +57,7 @@
|
||||
AdvancedKeyboardView* _advanced_keyboard_view;
|
||||
BOOL _advanced_keyboard_visible;
|
||||
BOOL _requesting_advanced_keyboard;
|
||||
CGFloat _keyboard_height_delta;
|
||||
CGFloat _keyboard_last_height;
|
||||
|
||||
// delayed mouse move event sending
|
||||
NSTimer* _mouse_move_event_timer;
|
||||
|
@ -51,7 +51,7 @@
|
||||
_advanced_keyboard_view = nil;
|
||||
_advanced_keyboard_visible = NO;
|
||||
_requesting_advanced_keyboard = NO;
|
||||
_keyboard_height_delta = 0;
|
||||
_keyboard_last_height = 0;
|
||||
|
||||
_session_toolbar_visible = NO;
|
||||
|
||||
@ -549,25 +549,46 @@
|
||||
#pragma mark -
|
||||
#pragma mark iOS Keyboard Notification Handlers
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)notification
|
||||
{
|
||||
CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
CGRect keyboardFrame = [[self view] convertRect:keyboardEndFrame toView:nil];
|
||||
// the keyboard is given in a portrait frame of reference
|
||||
- (BOOL)isLandscape {
|
||||
|
||||
UIInterfaceOrientation ori = [[UIApplication sharedApplication] statusBarOrientation];
|
||||
return ( ori == UIInterfaceOrientationLandscapeLeft || ori == UIInterfaceOrientationLandscapeRight );
|
||||
|
||||
}
|
||||
|
||||
CGFloat newHeightDelta = (keyboardFrame.size.height - _keyboard_height_delta);
|
||||
if (newHeightDelta < 0.1 && newHeightDelta > -0.1)
|
||||
return; // nothing changed
|
||||
|
||||
[UIView beginAnimations:nil context:NULL];
|
||||
- (void)shiftKeyboard: (NSNotification*)notification {
|
||||
|
||||
CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
|
||||
CGFloat previousHeight = _keyboard_last_height;
|
||||
|
||||
if( [self isLandscape] ) {
|
||||
// landscape has the keyboard based on x, so x can go negative
|
||||
_keyboard_last_height = keyboardEndFrame.size.width + keyboardEndFrame.origin.x;
|
||||
} else {
|
||||
// portrait has the keyboard based on the difference of the height and the frames y.
|
||||
CGFloat height = [[UIScreen mainScreen] bounds].size.height;
|
||||
_keyboard_last_height = height - keyboardEndFrame.origin.y;
|
||||
}
|
||||
|
||||
CGFloat shiftHeight = _keyboard_last_height - previousHeight;
|
||||
|
||||
[UIView beginAnimations:nil context:NULL];
|
||||
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
|
||||
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
|
||||
CGRect frame = [_session_scrollview frame];
|
||||
frame.size.height -= newHeightDelta;
|
||||
_keyboard_height_delta += newHeightDelta;
|
||||
frame.size.height -= shiftHeight;
|
||||
[_session_scrollview setFrame:frame];
|
||||
[_touchpointer_view setFrame:frame];
|
||||
[_touchpointer_view setFrame:frame];
|
||||
[UIView commitAnimations];
|
||||
|
||||
}
|
||||
|
||||
- (void)keyboardWillShow:(NSNotification *)notification
|
||||
{
|
||||
[self shiftKeyboard: notification];
|
||||
|
||||
[_touchpointer_view ensurePointerIsVisible];
|
||||
}
|
||||
|
||||
@ -583,17 +604,9 @@
|
||||
|
||||
- (void)keyboardWillHide:(NSNotification *)notification
|
||||
{
|
||||
CGRect keyboardEndFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
|
||||
[UIView beginAnimations:nil context:NULL];
|
||||
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
|
||||
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
|
||||
CGRect frame = [_session_scrollview frame];
|
||||
frame.size.height += [[self view] convertRect:keyboardEndFrame toView:nil].size.height;
|
||||
[_session_scrollview setFrame:frame];
|
||||
[_touchpointer_view setFrame:frame];
|
||||
[UIView commitAnimations];
|
||||
_keyboard_height_delta = 0;
|
||||
|
||||
[self shiftKeyboard: notification];
|
||||
|
||||
}
|
||||
|
||||
- (void)keyboardDidHide:(NSNotification*)notification
|
||||
|
Loading…
Reference in New Issue
Block a user