From 84e9738cbc57003c196ec96cf1bb65287dbd7cc7 Mon Sep 17 00:00:00 2001 From: Seoyeon Kim Date: Thu, 2 Jan 2020 19:00:02 +0900 Subject: [PATCH] [Tizen] Change the state of EventData to EDITING in RemoveText - 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 --- .../utc-Dali-Text-Controller.cpp | 42 ++++++++++++++++++++++ dali-toolkit/internal/text/text-controller.cpp | 5 +++ 2 files changed, 47 insertions(+) diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp index e819f7d..ec172d0 100755 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-Text-Controller.cpp @@ -1209,3 +1209,45 @@ int UtcDaliTextControllerDirectionCoverage(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; +} diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 6f9fe15..d8247bd 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -3738,6 +3738,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; } -- 2.7.4