Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update SDL controller to move stage when keyboard shown. #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
14 changes: 13 additions & 1 deletion src/video/uikit/SDL_uikitviewcontroller.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures
#endif

/*
---- Keyboard related functionality below this line ----
---- related functionality below this line ----
*/
#if SDL_IPHONE_KEYBOARD

Expand Down Expand Up @@ -349,6 +349,12 @@ - (void)keyboardWillShow:(NSNotification *)notification
kbrect = [self.view convertRect:kbrect fromView:nil];

[self setKeyboardHeight:(int)kbrect.size.height];
//move stage up
[UIView animateWithDuration:0.3 animations:^{
CGRect f = self.view.frame;
f.origin.y = -setKeyboardHeight;
self.view.frame = f;
}];
#endif
}

Expand All @@ -358,6 +364,12 @@ - (void)keyboardWillHide:(NSNotification *)notification
SDL_StopTextInput();
}
[self setKeyboardHeight:0];
//move stage back down
[UIView animateWithDuration:0.3 animations:^{
CGRect f = self.view.frame;
f.origin.y = 0.0f;
self.view.frame = f;
}];
}

- (void)textFieldTextDidChange:(NSNotification *)notification
Expand Down