[Tizen] Fix text cursor visibility issue 81/316681/1
authorBowon Ryu <bowon.ryu@samsung.com>
Mon, 26 Aug 2024 04:48:30 +0000 (13:48 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Tue, 27 Aug 2024 01:30:44 +0000 (10:30 +0900)
Ensured that the cursor remains active even when the keyboard is invisible but the control still has focus.

Change-Id: Ie4a57646f866eecc7c0082615155dd6cc0ad889c
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit/utc-Dali-TextEditor.cpp
automated-tests/src/dali-toolkit/utc-Dali-TextField.cpp
dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp
dali-toolkit/internal/controls/text-controls/text-field-impl.cpp

index fac21a0dc59a87f342ec888d228566eeea6244d6..60ca44d9f5f37706932d9c57e6f4bfcd044b6e81 100644 (file)
@@ -1459,6 +1459,53 @@ int utcDaliTextEditorTextChangedWithInputMethodContext(void)
   END_TEST;
 }
 
+int utcDaliTextEditorFocusWithInputMethodContext(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextEditorFocusWithInputMethodContext");
+  TextEditor editor = TextEditor::New();
+  DALI_TEST_CHECK(editor);
+
+  application.GetScene().Add(editor);
+  editor.SetProperty(DevelTextEditor::Property::ENABLE_EDITING, true);
+  application.SendNotification();
+  application.Render();
+
+  // get InputMethodContext
+  InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext(editor);
+  DALI_TEST_CHECK(inputMethodContext);
+
+  // connect StatusChangedSignal
+  editor.SetKeyInputFocus();
+
+  // keyboard shown
+  inputMethodContext.StatusChangedSignal().Emit(true);
+  application.SendNotification();
+  application.Render();
+
+  // keyboard hidden
+  inputMethodContext.StatusChangedSignal().Emit(false);
+  application.SendNotification();
+  application.Render();
+
+  // set focus and keyboard shown
+  editor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+  KeyboardFocusManager::Get().SetCurrentFocusActor(editor);
+
+  inputMethodContext.StatusChangedSignal().Emit(true);
+  application.SendNotification();
+  application.Render();
+
+  // keyboard hidden, focus should remain
+  inputMethodContext.StatusChangedSignal().Emit(false);
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(editor, KeyboardFocusManager::Get().GetCurrentFocusActor(), TEST_LOCATION);
+
+  END_TEST;
+}
+
 int utcDaliTextEditorInputStyleChanged01(void)
 {
   // The text-editor emits signals when the input style changes. These changes of style are
index 2f97873031845afd38f70edda1596db7b5255634..f033a33fc6342080621bcac6d3ec55d558b1ff15 100644 (file)
@@ -1839,6 +1839,53 @@ int utcDaliTextFieldInputFilterWithInputMethodContext(void)
   END_TEST;
 }
 
+int utcDaliTextFieldFocusWithInputMethodContext(void)
+{
+  ToolkitTestApplication application;
+  tet_infoline(" utcDaliTextFieldFocusWithInputMethodContext");
+  TextField field = TextField::New();
+  DALI_TEST_CHECK(field);
+
+  application.GetScene().Add(field);
+  field.SetProperty(DevelTextField::Property::ENABLE_EDITING, true);
+  application.SendNotification();
+  application.Render();
+
+  // get InputMethodContext
+  InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext(field);
+  DALI_TEST_CHECK(inputMethodContext);
+
+  // connect StatusChangedSignal
+  field.SetKeyInputFocus();
+
+  // keyboard shown
+  inputMethodContext.StatusChangedSignal().Emit(true);
+  application.SendNotification();
+  application.Render();
+
+  // keyboard hidden
+  inputMethodContext.StatusChangedSignal().Emit(false);
+  application.SendNotification();
+  application.Render();
+
+  // set focus and keyboard shown
+  field.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true);
+  KeyboardFocusManager::Get().SetCurrentFocusActor(field);
+
+  inputMethodContext.StatusChangedSignal().Emit(true);
+  application.SendNotification();
+  application.Render();
+
+  // keyboard hidden, focus should remain
+  inputMethodContext.StatusChangedSignal().Emit(false);
+  application.SendNotification();
+  application.Render();
+
+  DALI_TEST_EQUALS(field, KeyboardFocusManager::Get().GetCurrentFocusActor(), TEST_LOCATION);
+
+  END_TEST;
+}
+
 // Negative test for the textChanged signal.
 int utcDaliTextFieldTextChangedN(void)
 {
index dba3f820203c517f5730ec6185d62c2386560fe3..b856c0ff6bcf38c9d0fc88e88771a21d333c94e9 100644 (file)
@@ -1283,10 +1283,21 @@ void TextEditor::KeyboardStatusChanged(bool keyboardShown)
 {
   DALI_LOG_INFO(gTextEditorLogFilter, Debug::Verbose, "TextEditor::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown);
 
+  bool isFocused = false;
+
+  Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
+  if(keyboardFocusManager)
+  {
+    isFocused = keyboardFocusManager.GetCurrentFocusActor() == Self();
+  }
+
   // Just hide the grab handle when keyboard is hidden.
   if(!keyboardShown)
   {
-    mController->KeyboardFocusLostEvent();
+    if(!isFocused)
+    {
+      mController->KeyboardFocusLostEvent();
+    }
   }
   else
   {
index 11547072cd42d277526bd12d2b937eb81cf3176a..2d7fb5a3df2a02fc77874240da18c17dc30a3ba4 100644 (file)
@@ -1142,10 +1142,21 @@ void TextField::KeyboardStatusChanged(bool keyboardShown)
 {
   DALI_LOG_INFO(gTextFieldLogFilter, Debug::Verbose, "TextField::KeyboardStatusChanged %p keyboardShown %d\n", mController.Get(), keyboardShown);
 
+  bool isFocused = false;
+
+  Dali::Toolkit::KeyboardFocusManager keyboardFocusManager = Dali::Toolkit::KeyboardFocusManager::Get();
+  if(keyboardFocusManager)
+  {
+    isFocused = keyboardFocusManager.GetCurrentFocusActor() == Self();
+  }
+
   // Just hide the grab handle when keyboard is hidden.
   if(!keyboardShown)
   {
-    mController->KeyboardFocusLostEvent();
+    if(!isFocused)
+    {
+      mController->KeyboardFocusLostEvent();
+    }
   }
   else
   {