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=9fa42f12129a942fd6c7e8b9a3a62f3156e8fc81;hp=17456863180c97681ac4340b492958c516b17c7b;hb=a40939e617ca1a0b79aeb6af999cda7c70418be1;hpb=89f8a8b49600d9bd38db894616bb319ff4c6a9fa diff --git a/dali-toolkit/internal/text/text-controller.cpp b/dali-toolkit/internal/text/text-controller.cpp index 1745686..9fa42f1 100755 --- a/dali-toolkit/internal/text/text-controller.cpp +++ b/dali-toolkit/internal/text/text-controller.cpp @@ -49,6 +49,10 @@ const float MAX_FLOAT = std::numeric_limits::max(); const std::string EMPTY_STRING(""); +const std::string KEY_C_NAME = "c"; +const std::string KEY_V_NAME = "v"; +const std::string KEY_X_NAME = "x"; + const char * const PLACEHOLDER_TEXT = "text"; const char * const PLACEHOLDER_TEXT_FOCUSED = "textFocused"; const char * const PLACEHOLDER_COLOR = "color"; @@ -2099,6 +2103,24 @@ void Controller::GetPlaceholderProperty( Property::Map& map ) } } +Toolkit::DevelText::TextDirection::Type Controller::GetTextDirection() +{ + if( ( 0u == mImpl->mModel->mLogicalModel->mText.Count() ) ) + { + return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT; + } + + const Character character = mImpl->mModel->mLogicalModel->mText[0]; + Script script = TextAbstraction::GetCharacterScript( character ); + + if( TextAbstraction::IsRightToLeftScript( script ) ) + { + return Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT; + } + + return Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT; +} + // public : Relayout. Controller::UpdateTextType Controller::Relayout( const Size& size ) @@ -2322,6 +2344,7 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) { int keyCode = keyEvent.keyCode; const std::string& keyString = keyEvent.keyPressed; + const std::string keyName = keyEvent.keyPressedName; const bool isNullKey = ( 0 == keyCode ) && ( keyString.empty() ); @@ -2367,11 +2390,43 @@ bool Controller::KeyEvent( const Dali::KeyEvent& keyEvent ) mImpl->mEventData->mCheckScrollAmount = true; Event event( Event::CURSOR_KEY_EVENT ); event.p1.mInt = keyCode; + event.p2.mBool = keyEvent.IsShiftModifier(); mImpl->mEventData->mEventQueue.push_back( event ); // Will request for relayout. relayoutNeeded = true; } + else if ( Dali::DevelKey::DALI_KEY_CONTROL_LEFT == keyCode || Dali::DevelKey::DALI_KEY_CONTROL_RIGHT == keyCode ) + { + // Left or Right Control key event is received before Ctrl-C/V/X key event is received + // If not handle it here, any selected text will be deleted + + // Do nothing + return false; + } + else if ( keyEvent.IsCtrlModifier() ) + { + bool consumed = false; + if (keyName == KEY_C_NAME) + { + // Ctrl-C to copy the selected text + TextPopupButtonTouched( Toolkit::TextSelectionPopup::COPY ); + consumed = true; + } + else if (keyName == KEY_V_NAME) + { + // Ctrl-V to paste the copied text + TextPopupButtonTouched( Toolkit::TextSelectionPopup::PASTE ); + consumed = true; + } + else if (keyName == KEY_X_NAME) + { + // Ctrl-X to cut the selected text + TextPopupButtonTouched( Toolkit::TextSelectionPopup::CUT ); + consumed = true; + } + return consumed; + } else if( ( Dali::DALI_KEY_BACKSPACE == keyCode ) || ( Dali::DevelKey::DALI_KEY_DELETE == keyCode ) ) { @@ -2689,7 +2744,17 @@ ImfManager::ImfCallbackData Controller::OnImfEvent( ImfManager& imfManager, cons if( retrieveText ) { - mImpl->GetText( numberOfWhiteSpaces, text ); + if( !mImpl->IsShowingPlaceholderText() ) + { + // Retrieves the normal text string. + mImpl->GetText( numberOfWhiteSpaces, text ); + } + else + { + // When the current text is Placeholder Text, the surrounding text should be empty string. + // It means DALi should send empty string ("") to IME. + text = ""; + } } ImfManager::ImfCallbackData callbackData( ( retrieveText || retrieveCursor ), cursorPosition, text, false ); @@ -3543,6 +3608,10 @@ void Controller::ProcessModifyEvents() { // When the text is being modified, delay cursor blinking mImpl->mEventData->mDecorator->DelayCursorBlink(); + + // Update selection position after modifying the text + mImpl->mEventData->mLeftSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition; + mImpl->mEventData->mRightSelectionPosition = mImpl->mEventData->mPrimaryCursorPosition; } // Discard temporary text @@ -3645,7 +3714,7 @@ bool Controller::DeleteEvent( int keyCode ) 1, UPDATE_INPUT_STYLE ); } - else if( ( mImpl->mEventData->mPrimaryCursorPosition >= 0 ) && ( keyCode == Dali::DevelKey::DALI_KEY_DELETE ) ) + else if( keyCode == Dali::DevelKey::DALI_KEY_DELETE ) { // Remove the character after the current cursor position removed = RemoveText( 0, @@ -3784,6 +3853,7 @@ void Controller::ClearFontData() mImpl->mOperationsPending = static_cast( mImpl->mOperationsPending | VALIDATE_FONTS | SHAPE_TEXT | + BIDI_INFO | GET_GLYPH_METRICS | LAYOUT | UPDATE_LAYOUT_SIZE |