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=4eb5662ea8e8e802c7ac265c8103b98a33e6e80a;hp=8500659e21a75267bf2a90ae550b70dd95af1dfc;hb=660728e83fd72194f53642fd74c09db561f88496;hpb=3c2a5c792a154d11bd97cf587ae142b277ad45c0 diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 8500659..4eb5662 100644 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -1498,6 +1498,18 @@ float Controller::GetScrollAmountByUserInput() return scrollAmount; } +bool Controller::GetTextScrollInfo( float& scrollPosition, float& controlHeight, float& layoutHeight ) +{ + const Vector2& layout = mImpl->mModel->mVisualModel->GetLayoutSize(); + bool isScrolled; + + controlHeight = mImpl->mModel->mVisualModel->mControlSize.height; + layoutHeight = layout.height; + scrollPosition = mImpl->mModel->mScrollPosition.y; + isScrolled = !Equals( mImpl->mModel->mScrollPosition.y, mImpl->mModel->mScrollPositionLast.y, Math::MACHINE_EPSILON_1 ); + return isScrolled; +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout( const Size& size ) @@ -1707,8 +1719,15 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) int keyCode = keyEvent.keyCode; const std::string& keyString = keyEvent.keyPressed; + const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() ); + // Pre-process to separate modifying events from non-modifying input events. - if( Dali::DALI_KEY_ESCAPE == keyCode ) + if( isNullKey ) + { + // In some platforms arrive key events with no key code. + // Do nothing. + } + else if( Dali::DALI_KEY_ESCAPE == keyCode ) { // Escape key is a special case which causes focus loss KeyboardFocusLostEvent(); @@ -1718,8 +1737,29 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) ( Dali::DALI_KEY_CURSOR_UP == keyCode ) || ( Dali::DALI_KEY_CURSOR_DOWN == keyCode ) ) { - mImpl->mEventData->mCheckScrollAmount = true; + // If don't have any text, do nothing. + if( !mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters ) + { + return false; + } + + uint32_t cursorPosition = mImpl->mEventData->mPrimaryCursorPosition; + uint32_t numberOfCharacters = mImpl->mTextUpdateInfo.mPreviousNumberOfCharacters; + uint32_t cursorLine = mImpl->mModel->mVisualModel->GetLineOfCharacter( cursorPosition ); + uint32_t numberOfLines = mImpl->mModel->GetNumberOfLines(); + + // Logic to determine whether this text control will lose focus or not. + if( ( Dali::DALI_KEY_CURSOR_LEFT == keyCode && 0 == cursorPosition ) || + ( Dali::DALI_KEY_CURSOR_RIGHT == keyCode && numberOfCharacters == cursorPosition) || + ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && cursorLine == numberOfLines -1 ) || + ( Dali::DALI_KEY_CURSOR_DOWN == keyCode && numberOfCharacters == cursorPosition && cursorLine -1 == numberOfLines -1 ) || + ( Dali::DALI_KEY_CURSOR_UP == keyCode && cursorLine == 0 ) || + ( Dali::DALI_KEY_CURSOR_UP == keyCode && numberOfCharacters == cursorPosition && cursorLine == 1 ) ) + { + return false; + } + mImpl->mEventData->mCheckScrollAmount = true; Event event( Event::CURSOR_KEY_EVENT ); event.p1.mInt = keyCode; mImpl->mEventData->mEventQueue.push_back( event ); @@ -1757,6 +1797,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) if ( ( mImpl->mEventData->mState != EventData::INTERRUPTED ) && ( mImpl->mEventData->mState != EventData::INACTIVE ) && + ( !isNullKey ) && ( Dali::DALI_KEY_SHIFT_LEFT != keyCode ) ) { // Should not change the state if the key is the shift send by the imf manager. @@ -1897,7 +1938,7 @@ void Controller::LongPressEvent( Gesture::State state, float x, float y ) mImpl->RequestRelayout(); } - else if( !mImpl->IsClipboardVisible() ) + else { // Reset the imf manger to commit the pre-edit before selecting the text. mImpl->ResetImfManager();