From c20fd998976fba9add70c3e4694abb538f95dcd0 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Mon, 29 Jul 2013 18:01:22 +0000 Subject: [PATCH] ios stuff --- src/GUIManager/GUIManager.cpp | 3 +++ src/Utils/IosApi/IosApi.mm | 5 +++-- src/Utils/IosApi/ObjC/ViewControllerTemplate.mm | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/GUIManager/GUIManager.cpp b/src/GUIManager/GUIManager.cpp index 5de1d9d..88c1770 100644 --- a/src/GUIManager/GUIManager.cpp +++ b/src/GUIManager/GUIManager.cpp @@ -9,9 +9,12 @@ const std::string CONST_CLICK_SIGNAL_NAME = "OnClick"; const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag"; + boost::mutex KeyMutex; void GuiManagerSetKeyboardText(std::string newText) { + KeyMutex.lock(); ResourceManager->GUIManager.SetTextSignal(newText); + KeyMutex.unlock(); } diff --git a/src/Utils/IosApi/IosApi.mm b/src/Utils/IosApi/IosApi.mm index 1658462..1bb16d7 100644 --- a/src/Utils/IosApi/IosApi.mm +++ b/src/Utils/IosApi/IosApi.mm @@ -78,8 +78,9 @@ void GuiManagerSetKeyboardText(std::string newText); //Find it in GUIManager.cpp void SetKeyboardText(const char* newText) { - GuiManagerSetKeyboardText(newText); - NSLog(@"text: %s", newText); + SE::PerformInMainThreadAsync(boost::bind(&GuiManagerSetKeyboardText, newText)); + //GuiManagerSetKeyboardText(newText); + //NSLog(@"text: %s", newText); } } //namespace SE diff --git a/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm b/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm index 3e10b49..868584d 100644 --- a/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm +++ b/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm @@ -71,6 +71,10 @@ void SetKeyboardText(const char* newText); _hiddenTextField = [[UITextField alloc] initWithFrame:CGRectMake(-200,-200,0,0)]; + //[_hiddenTextField setReturnKeyType: UIReturnKeyDone]; + + _hiddenTextField.autocorrectionType = UITextAutocorrectionTypeNo; + [self.view addSubview:_hiddenTextField]; extKeyboardTextView = _hiddenTextField; @@ -145,6 +149,12 @@ void SetKeyboardText(const char* newText); NSLog(@"End"); } +- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ + if([string isEqualToString:@"\n"]) + [textField resignFirstResponder]; + return YES; +} #pragma mark - GLKView and GLKViewController delegate methods