[Tizen] Fix text cursor visibility issue 82/316682/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:43:51 +0000 (10:43 +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 6a5745cc2a82298899a59f36e800407c772b9e8e..4c1137b11ce63c0fe596477e370ad7c5d1d4fc6d 100644 (file)
@@ -1476,6 +1476,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 d098f99eee0a1e552c9c1fba0ffc277a1d783430..7fbd1dfed0571500461ee921f9643d51cdd0b84c 100644 (file)
@@ -1857,6 +1857,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 8bc839771b58b7960b232d0e03483a5b4ab700e0..87844413cf9bcb59f71aaf3250f7bc917cc10363 100644 (file)
@@ -1304,10 +1304,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 a2702de24af9f04c4bdc14682ea3a40915659f36..f41be6a86fca624ea22b4edd2ca858546bc4c93b 100644 (file)
@@ -1137,10 +1137,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
   {