X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller.cpp;h=68555b718ad9e50e512f1b520c41549b658f72ad;hp=4e69a4e9df6d8ba403dcddd162f745ac2d2c67c8;hb=df2e95e1470c73ed44bfa2cfe1c65d68bcb4e5c9;hpb=079795bcb6a8aab48e5e4252a86f524e6749fcbb diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 4e69a4e..68555b7 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1016,7 +1016,12 @@ void Controller::CalculateTextAlignment( const Size& size ) // Get the direction of the first character. const CharacterDirection firstParagraphDirection = mImpl->mLogicalModel->GetCharacterDirection( 0u ); - const Size& actualSize = mImpl->mVisualModel->GetActualSize(); + Size actualSize = mImpl->mVisualModel->GetActualSize(); + if( fabsf( actualSize.height ) < Math::MACHINE_EPSILON_1000 ) + { + // Get the line height of the default font. + actualSize.height = mImpl->GetDefaultFontLineHeight(); + } // If the first paragraph is right to left swap ALIGN_BEGIN and ALIGN_END; LayoutEngine::HorizontalAlignment horizontalAlignment = mImpl->mLayoutEngine.GetHorizontalAlignment(); @@ -1109,16 +1114,18 @@ void Controller::KeyboardFocusLostEvent() if( mImpl->mEventData ) { - mImpl->ChangeState( EventData::INACTIVE ); - - if( mImpl->IsShowingPlaceholderText() ) + if ( EventData::INTERRUPTED != mImpl->mEventData->mState ) { - // Revert to regular placeholder-text when not editing - ShowPlaceholderText(); - } + mImpl->ChangeState( EventData::INACTIVE ); - mImpl->RequestRelayout(); + if( mImpl->IsShowingPlaceholderText() ) + { + // Revert to regular placeholder-text when not editing + ShowPlaceholderText(); + } + } } + mImpl->RequestRelayout(); } bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) @@ -1152,10 +1159,17 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) { textChanged = BackspaceKeyEvent(); } - else if ( IsKey( keyEvent, Dali::DALI_KEY_POWER ) || IsKey( keyEvent, Dali::DALI_KEY_MENU ) ) + else if ( IsKey( keyEvent, Dali::DALI_KEY_POWER ) ) + { + mImpl->ChangeState( EventData::INTERRUPTED ); // State is not INACTIVE as expect to return to edit mode. + // Avoids calling the InsertText() method which can delete selected text + } + else if ( IsKey( keyEvent, Dali::DALI_KEY_MENU ) || + IsKey( keyEvent, Dali::DALI_KEY_HOME ) ) { - // Do nothing when the Power or Menu Key is pressed. - // It avoids call the InsertText() method and delete the selected text. + mImpl->ChangeState( EventData::INACTIVE ); + // Menu/Home key behaviour does not allow edit mode to resume like Power key + // Avoids calling the InsertText() method which can delete selected text } else { @@ -1168,7 +1182,10 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) textChanged = true; } - mImpl->ChangeState( EventData::EDITING ); // todo Confirm this is the best place to change the state of + if ( mImpl->mEventData->mState != EventData::INTERRUPTED && mImpl->mEventData->mState != EventData::INACTIVE ) + { + mImpl->ChangeState( EventData::EDITING ); + } mImpl->RequestRelayout(); }