From: Seoyeon Kim Date: Thu, 2 Jan 2020 10:00:02 +0000 (+0900) Subject: Change the state of EventData to EDITING in RemoveText X-Git-Tag: dali_1.4.53~5 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=f7ea20e4f10cf11c334492f92e140770d9c8d22f;ds=sidebyside 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 --- 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 e1787c9..b756ed7 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 @@ -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; +} diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index a3d77d4..9d56a0e 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -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; }