Change the state of EventData to EDITING in RemoveText 92/221492/1
authorSeoyeon Kim <seoyeon2.kim@samsung.com>
Thu, 2 Jan 2020 10:00:02 +0000 (19:00 +0900)
committerSeoyeon Kim <seoyeon2.kim@samsung.com>
Fri, 3 Jan 2020 04:48:33 +0000 (13:48 +0900)
- Currently, in certain cases, even if Backspace key is pressed
 after cursor blink is stopped, cursor blink does not restart and
 the cursor is also not shown.

- It means, after EventData is changed to INACTIVE state due to
 KeyboardFocusLostEvent(), StopCursorBlink() is called.
  After that, in RemoveText(), which is called in Backspace key,
 EventData cannot be changed to EDITING state and StartCursorBlink() is not called.
  On the other hand, when the character commits or the arrow keys are pressed,
 EventData is changed to EDITING state and the cursor is displayed on screen.

- So, added 'ChangeState( EventData::EDITING )' when the state is INACTIVE.

Change-Id: Ib79dfdc6f7308d084772f62dc49918a694cfc438
Signed-off-by: Seoyeon Kim <seoyeon2.kim@samsung.com>
automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp
dali-toolkit/internal/text/text-controller.cpp

index e1787c9..b756ed7 100755 (executable)
@@ -1086,3 +1086,45 @@ int UtcDaliTextControllerMaxLengthSetText(void)
 
   END_TEST;
 }
+
+int UtcDaliTextControllerRemoveTextChangeEventData(void)
+{
+  tet_infoline(" UtcDaliTextControllerRemoveTextChangeEventData");
+  ToolkitTestApplication application;
+
+  // Creates a text controller.
+  ControllerPtr controller = Controller::New();
+
+  ConfigureTextField( controller );
+
+  // Set the text
+  const std::string text( "Hello World!" );
+  controller->SetText( text );
+  controller->SetInputFontPointSize( 1.0f );
+
+  // Get the implementation of the text controller
+  Controller::Impl& mImpl = Controller::Impl::GetImplementation( *controller.Get() );
+
+  DALI_TEST_EQUALS( EventData::INACTIVE, mImpl.mEventData->mState, TEST_LOCATION );
+
+  // Send DELETE_SURROUNDING event
+  InputMethodContext::EventData imfEvent = InputMethodContext::EventData( InputMethodContext::DELETE_SURROUNDING, "", -1, 1 );
+  InputMethodContext inputMethodContext = InputMethodContext::New();
+  controller->OnInputMethodContextEvent( inputMethodContext, imfEvent );
+
+  // Force to update the model.
+  controller->GetNaturalSize();
+
+  // Simulate a key event to delete text
+  controller->KeyEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Dali::KeyEvent::Down ) );
+
+  DALI_TEST_EQUALS( EventData::EDITING, mImpl.mEventData->mState, TEST_LOCATION );
+
+  // Perform a relayout
+  const Size size( Dali::Stage::GetCurrent().GetSize() );
+  controller->Relayout( size );
+
+  tet_result(TET_PASS);
+
+  END_TEST;
+}
index a3d77d4..9d56a0e 100755 (executable)
@@ -3735,6 +3735,11 @@ bool Controller::RemoveText( int cursorOffset,
 
       mImpl->mEventData->mScrollAfterDelete = true;
 
+      if( EventData::INACTIVE == mImpl->mEventData->mState )
+      {
+        mImpl->ChangeState( EventData::EDITING );
+      }
+
       DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::RemoveText %p removed %d\n", this, numberOfCharacters );
       removed = true;
     }