Skip to content

Commit

Permalink
iOS: Clicking onthe background dismisses onscreen keyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Apr 29, 2024
1 parent f82b1ab commit 0cdcab1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/interop_ios.m
Expand Up @@ -44,6 +44,7 @@ @interface CCAppDelegate : UIResponder<UIApplicationDelegate>
static CCViewController* cc_controller;
static UIWindow* win_handle;
static UIView* view_handle;
static cc_bool launcherMode;

static void AddTouch(UITouch* t) {
CGPoint loc = [t locationInView:view_handle];
Expand Down Expand Up @@ -93,6 +94,9 @@ @implementation CCWindow
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent *)event {
// touchesBegan:withEvent - iOS 2.0
for (UITouch* t in touches) AddTouch(t);

// clicking on the background should dismiss onscren keyboard
if (launcherMode) { [view_handle endEditing:NO]; }
}

- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent *)event {
Expand Down Expand Up @@ -687,6 +691,7 @@ cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
*--------------------------------------------------------2D window--------------------------------------------------------*
*#########################################################################################################################*/
void Window_Create2D(int width, int height) {
launcherMode = true;
CGRect bounds = DoCreateWindow();

view_handle = [[UIView alloc] initWithFrame:bounds];
Expand Down Expand Up @@ -716,8 +721,10 @@ - (void)layoutSubviews {
@end

void Window_Create3D(int width, int height) {
// CAEAGLLayer - iOS 2.0
launcherMode = false;
CGRect bounds = DoCreateWindow();

// CAEAGLLayer - iOS 2.0
view_handle = [[CCGLView alloc] initWithFrame:bounds];
view_handle.multipleTouchEnabled = true;
cc_controller.view = view_handle;
Expand Down

0 comments on commit 0cdcab1

Please sign in to comment.