From a968ce2ad06f8f75c529a79016eaeaa7410f80a5 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Mon, 6 Jan 2014 07:44:33 +0000 Subject: [PATCH] ios stuff + keyboard --- include/GUIManager/GUIManager.h | 3 +-- include/Utils/IosApi/IosApi.h | 4 ++-- src/GUIManager/ButtonWidget.cpp | 7 +------ src/GUIManager/GUIManager.cpp | 11 +++++++++-- src/Utils/IosApi/IosApi.mm | 16 +++++++++++++++- src/Utils/IosApi/ObjC/ViewControllerTemplate.mm | 5 ++++- 6 files changed, 32 insertions(+), 14 deletions(-) diff --git a/include/GUIManager/GUIManager.h b/include/GUIManager/GUIManager.h index a77562e..ef1a337 100644 --- a/include/GUIManager/GUIManager.h +++ b/include/GUIManager/GUIManager.h @@ -139,9 +139,8 @@ protected: std::map TotalShift; boost::mutex WidgetListMutex; - - bool KeyboardIsOnScreen; public: + bool KeyboardIsOnScreen; boost::signal KeyPressedSignal; boost::signal SetTextSignal; diff --git a/include/Utils/IosApi/IosApi.h b/include/Utils/IosApi/IosApi.h index 9bb0fb8..c4b25bc 100644 --- a/include/Utils/IosApi/IosApi.h +++ b/include/Utils/IosApi/IosApi.h @@ -23,9 +23,9 @@ std::string IosGetFilePathUserData(const std::string& filename); void IosSwitchToScreen(); void ShowKeyboard(std::string text); - void HideKeyboard(); +void ClearKeyboardText(); - bool IsIpad(); +bool IsIpad(); } //namespace SE diff --git a/src/GUIManager/ButtonWidget.cpp b/src/GUIManager/ButtonWidget.cpp index 81e3bb3..d84764d 100644 --- a/src/GUIManager/ButtonWidget.cpp +++ b/src/GUIManager/ButtonWidget.cpp @@ -685,12 +685,7 @@ void TEdit::SetText(const std::string& newText) void TEdit::OnSetAllText(std::string newText) { - if (newText != TextParams.Text) - { - TextParams.Text = newText; - - RefreshTextTriangleList(); - } + SetText(newText); } diff --git a/src/GUIManager/GUIManager.cpp b/src/GUIManager/GUIManager.cpp index 7ea68aa..b0d4d34 100644 --- a/src/GUIManager/GUIManager.cpp +++ b/src/GUIManager/GUIManager.cpp @@ -10,7 +10,8 @@ const std::string CONST_DRAG_SIGNAL_NAME = "OnDrag"; const std::string CONST_TAPDOWN_SIGNAL_NAME = "OnTapDown"; - boost::mutex KeyMutex; +boost::mutex KeyMutex; + void GuiManagerSetKeyboardText(std::string newText) { KeyMutex.lock(); @@ -18,8 +19,14 @@ void GuiManagerSetKeyboardText(std::string newText) KeyMutex.unlock(); } +void GuiOnKeyboardHide() +{ + ResourceManager->GUIManager.KeyboardIsOnScreen = false; + ResourceManager->GUIManager.OnKeyboardHideSignal(); + ResourceManager->GUIManager.OnKeyboardHideSignal.disconnect_all_slots(); +} - + TGUIManager::TGUIManager() : KeyboardIsOnScreen(false) { diff --git a/src/Utils/IosApi/IosApi.mm b/src/Utils/IosApi/IosApi.mm index 8455bc2..fc32cb0 100644 --- a/src/Utils/IosApi/IosApi.mm +++ b/src/Utils/IosApi/IosApi.mm @@ -74,6 +74,11 @@ void HideKeyboard() [extKeyboardTextView resignFirstResponder]; } +void ClearKeyboardText() +{ + extKeyboardTextView.text = @""; +} + void GuiManagerSetKeyboardText(std::string newText); //Find it in GUIManager.cpp void SetKeyboardText(const char* newText) @@ -83,12 +88,21 @@ void SetKeyboardText(const char* newText) //NSLog(@"text: %s", newText); } - bool IsIpad() +void GuiOnKeyboardHide(); //Find it in GUIManager.cpp + + +void OnKeyboardHide() +{ + SE::PerformInMainThreadAsync(&GuiOnKeyboardHide); +} + +bool IsIpad() { if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) { return YES; /* Device is iPad */ } + return NO; } } //namespace SE diff --git a/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm b/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm index 8dfc5c7..d2243e9 100644 --- a/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm +++ b/src/Utils/IosApi/ObjC/ViewControllerTemplate.mm @@ -18,7 +18,7 @@ namespace SE { void SetKeyboardText(const char* newText); - +void OnKeyboardHide(); } @@ -157,7 +157,10 @@ void SetKeyboardText(const char* newText); - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if([string isEqualToString:@"\n"]) + { [textField resignFirstResponder]; + SE::OnKeyboardHide(); + } return YES; }