X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=6b1e31fabf0b4a807a5be21d826299edf7ec2aca;hb=4c1f4bfb9eb5b956b64a6c9bf077217fc0ca9234;hp=6bcb90c43dfa54949c4b17236d77506669e74fc6;hpb=f04a5829e7e2a5f434264d258f16b1417941de6e;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 6bcb90c..6b1e31f 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -77,6 +77,9 @@ void Controller::SetText( const std::string& text ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::SetText\n" ); + // Reset keyboard as text changed + mImpl->ResetImfManager(); + // Remove the previously set text ResetText(); @@ -142,8 +145,8 @@ void Controller::SetText( const std::string& text ) mImpl->mEventData->mEventQueue.clear(); } - // Reset keyboard as text changed - mImpl->ResetImfManager(); + // Notify IMF as text changed + NotifyImfManager(); // Do this last since it provides callbacks into application code mImpl->mControlInterface.TextChanged(); @@ -226,7 +229,7 @@ int Controller::GetMaximumNumberOfCharacters() return mImpl->mMaximumNumberOfCharacters; } -void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, bool userDefined ) +void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily ) { if( !mImpl->mFontDefaults ) { @@ -234,8 +237,8 @@ void Controller::SetDefaultFontFamily( const std::string& defaultFontFamily, boo } mImpl->mFontDefaults->mFontDescription.family = defaultFontFamily; - DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s userDefined: %s\n", defaultFontFamily.c_str(), userDefined ? "true":"false" ); - mImpl->mUserDefinedFontFamily = userDefined; + DALI_LOG_INFO( gLogFilter, Debug::General, "Controller::SetDefaultFontFamily %s\n", defaultFontFamily.c_str()); + mImpl->mUserDefinedFontFamily = true; // Clear the font-specific data ClearFontData(); @@ -401,11 +404,10 @@ void Controller::UpdateAfterFontChange( std::string& newDefaultFont ) { DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange"); - ClearFontData(); - if ( !mImpl->mUserDefinedFontFamily ) // If user defined font then should not update when system font changes { DALI_LOG_INFO( gLogFilter, Debug::Concise, "Controller::UpdateAfterFontChange newDefaultFont(%s)\n", newDefaultFont.c_str() ); + ClearFontData(); mImpl->mFontDefaults->mFontDescription.family = newDefaultFont; mImpl->UpdateModel( ALL_OPERATIONS ); mImpl->QueueModifyEvent( ModifyEvent::TEXT_REPLACED ); @@ -781,18 +783,18 @@ void Controller::ProcessModifyEvents() for( unsigned int i=0; iIsShowingPlaceholderText() ) @@ -1253,7 +1255,7 @@ void Controller::KeyboardFocusLostEvent() { mImpl->ChangeState( EventData::INACTIVE ); - if( mImpl->IsShowingPlaceholderText() ) + if( !mImpl->IsShowingRealText() ) { // Revert to regular placeholder-text when not editing ShowPlaceholderText(); @@ -1520,6 +1522,11 @@ void Controller::TapEvent( unsigned int tapCount, float x, float y ) else if( EventData::EDITING != mImpl->mEventData->mState && EventData::EDITING_WITH_GRAB_HANDLE != mImpl->mEventData->mState ) { + if( mImpl->IsShowingPlaceholderText() && ! mImpl->IsFocusedPlaceholderAvailable() ) + { + // Hide placeholder text + ResetText(); + } // Show cursor on first tap mImpl->ChangeState( EventData::EDITING ); relayoutNeeded = true; @@ -1603,6 +1610,9 @@ void Controller::LongPressEvent( Gesture::State state, float x, float y ) } else { + // Reset the imf manger to commit the pre-edit before selecting the text. + mImpl->ResetImfManager(); + SelectEvent( x, y, false ); } } @@ -1807,6 +1817,7 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons case ImfManager::COMMIT: { InsertText( imfEvent.predictiveString, Text::Controller::COMMIT ); + update=true; requestRelayout = true; break; } @@ -1900,11 +1911,10 @@ bool Controller::BackspaceKeyEvent() if( removed ) { - // This is to reset the virtual keyboard to Upper-case - if( 0u == mImpl->mLogicalModel->mText.Count() ) - { - NotifyImfManager(); - } + DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p DALI_KEY_BACKSPACE RemovedText\n", this ); + // Notifiy the IMF manager after text changed + // Automatic Upper-case and restarting prediction on an existing word require this. + NotifyImfManager(); if( 0u != mImpl->mLogicalModel->mText.Count() || !mImpl->IsPlaceholderAvailable() ) @@ -1923,17 +1933,20 @@ bool Controller::BackspaceKeyEvent() void Controller::NotifyImfManager() { - ImfManager imfManager = ImfManager::Get(); - - if( imfManager ) + if( mImpl->mEventData ) { - // Notifying IMF of a cursor change triggers a surrounding text request so updating it now. - std::string text; - GetText( text ); - imfManager.SetSurroundingText( text ); + ImfManager imfManager = ImfManager::Get(); - imfManager.SetCursorPosition( GetLogicalCursorPosition() ); - imfManager.NotifyCursorPosition(); + if( imfManager ) + { + // Notifying IMF of a cursor change triggers a surrounding text request so updating it now. + std::string text; + GetText( text ); + imfManager.SetSurroundingText( text ); + + imfManager.SetCursorPosition( GetLogicalCursorPosition() ); + imfManager.NotifyCursorPosition(); + } } }