Fix cursor position update issue 03/281303/2
authorBowon Ryu <bowon.ryu@samsung.com>
Thu, 15 Sep 2022 10:02:37 +0000 (19:02 +0900)
committerBowon Ryu <bowon.ryu@samsung.com>
Thu, 15 Sep 2022 10:53:46 +0000 (19:53 +0900)
When a text controller has focus and loses keyboard focus,
the controller is in the INACTIVE state.
But in this case, when the cursor position is updated from a key event,
there is an issue that the position is not updated due to the wrong state.

This patch changes the state of controller to EDITING in the issue case.

Change-Id: Idea21a5486a7c076a59ad5dcd74c5b3343c1e2fe
Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
dali-toolkit/internal/text/controller/text-controller-event-handler.cpp

index 53b45f2..cbff44c 100755 (executable)
@@ -1146,6 +1146,9 @@ int UtcDaliTextControllerCheckInputFontPointSizeChanged(void)
   const Size size( application.GetScene().GetSize() );
   controller->Relayout(size);
 
+  // For coverage
+  controller->KeyEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Dali::KeyEvent::DOWN ) );
+
   tet_result(TET_PASS);
 
   END_TEST;
index e351342..ca6d7f5 100644 (file)
@@ -191,6 +191,12 @@ bool Controller::EventHandler::KeyEvent(Controller& controller, const Dali::KeyE
         return false;
       }
 
+      if(controller.mImpl->mEventData->mState == EventData::INACTIVE)
+      {
+        // Cursor position will be updated
+        controller.mImpl->ChangeState(EventData::EDITING);
+      }
+
       controller.mImpl->mEventData->mCheckScrollAmount = true;
       Event event(Event::CURSOR_KEY_EVENT);
       event.p1.mInt  = keyCode;