X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Ftext-input%2Ftext-input-impl.cpp;h=d82cb4f318a9e67ef0a23658baa6c1f3e3615745;hp=2ec817095e3ed4ed10eb13cd618db4480cf9fde5;hb=120c462b74858ad2316c748b8656f23ed32779ea;hpb=8b1f3f9ca0409d954a6fa7c35fbc43523b2ddc0e diff --git a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp index 2ec8170..d82cb4f 100644 --- a/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp +++ b/base/dali-toolkit/internal/controls/text-input/text-input-impl.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -51,9 +52,6 @@ const char* DEFAULT_SELECTION_HANDLE_ONE( DALI_IMAGE_DIR "text-input-selection-h const char* DEFAULT_SELECTION_HANDLE_TWO( DALI_IMAGE_DIR "text-input-selection-handle-right.png" ); const char* DEFAULT_SELECTION_HANDLE_ONE_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-left-press.png" ); const char* DEFAULT_SELECTION_HANDLE_TWO_PRESSED( DALI_IMAGE_DIR "text-input-selection-handle-right-press.png" ); -const char* DEFAULT_CURSOR( DALI_IMAGE_DIR "cursor.png" ); - -const Vector4 DEFAULT_CURSOR_IMAGE_9_BORDER( 2.0f, 2.0f, 2.0f, 2.0f ); const std::size_t CURSOR_BLINK_INTERVAL = 500; ///< Cursor blink interval const float CHARACTER_THRESHOLD( 2.5f ); ///< the threshold of a line. @@ -66,8 +64,9 @@ const Vector3 DEFAULT_HANDLE_ONE_OFFSET(0.0f, -5.0f, 0.0f); ///< const Vector3 DEFAULT_HANDLE_TWO_OFFSET(0.0f, -5.0f, 0.0f); ///< Handle Two's Offset const float TOP_HANDLE_TOP_OFFSET( 34.0f); ///< Offset between top handle and cutCopyPaste pop-up const float BOTTOM_HANDLE_BOTTOM_OFFSET(34.0f); ///< Offset between bottom handle and cutCopyPaste pop-up -const float CURSOR_THICKNESS(6.0f); +const float CURSOR_THICKNESS(4.0f); const Degree CURSOR_ANGLE_OFFSET(2.0f); ///< Offset from the angle of italic angle. +const Vector4 DEFAULT_CURSOR_COLOR(1.0f, 1.0f, 1.0f, 1.0f); const std::string NEWLINE( "\n" ); @@ -87,36 +86,6 @@ enum SelectionState SelectionFinished ///< Finished selected section }; -/** - * Whether the given style is the default style or not. - * @param[in] style The given style. - * @return \e true if the given style is the default. Otherwise it returns \e false. - */ -bool IsDefaultStyle( const TextStyle& style ) -{ - return DEFAULT_TEXT_STYLE == style; -} - -/** - * Whether the given styled text is using the default style or not. - * @param[in] textArray The given text. - * @return \e true if the given styled text is using the default style. Otherwise it returns \e false. - */ -bool IsTextDefaultStyle( const Toolkit::MarkupProcessor::StyledTextArray& textArray ) -{ - for( Toolkit::MarkupProcessor::StyledTextArray::const_iterator it = textArray.begin(), endIt = textArray.end(); it != endIt; ++it ) - { - const TextStyle& style( (*it).mStyle ); - - if( !IsDefaultStyle( style ) ) - { - return false; - } - } - - return true; -} - std::size_t FindVisibleCharacterLeft( std::size_t cursorPosition, const Toolkit::TextView::CharacterLayoutInfoContainer& characterLayoutInfoTable ) { for( Toolkit::TextView::CharacterLayoutInfoContainer::const_reverse_iterator it = characterLayoutInfoTable.rbegin() + characterLayoutInfoTable.size() - cursorPosition, endIt = characterLayoutInfoTable.rend(); @@ -211,8 +180,9 @@ const Property::Index TextInput::PASTE_BUTTON_POSITION_PRIORITY_PROPERTY = const Property::Index TextInput::SELECT_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+11; const Property::Index TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+12; const Property::Index TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+13; - const Property::Index TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+14; +const Property::Index TextInput::CURSOR_COLOR_PROPERTY = Internal::TextInput::TEXTINPUT_PROPERTY_START_INDEX+15; + namespace Internal { @@ -251,6 +221,8 @@ PropertyRegistration property12( typeRegistration, "select-button-position-prior PropertyRegistration property13( typeRegistration, "select-all-button-position-priority", Toolkit::TextInput::SELECT_ALL_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); PropertyRegistration property14( typeRegistration, "clipboard-button-position-priority", Toolkit::TextInput::CLIPBOARD_BUTTON_POSITION_PRIORITY_PROPERTY, Property::UNSIGNED_INTEGER, &TextInput::SetProperty, &TextInput::GetProperty ); PropertyRegistration property15( typeRegistration, "popup-offset-from-text", Toolkit::TextInput::POP_UP_OFFSET_FROM_TEXT_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); +PropertyRegistration property16( typeRegistration, "cursor-color", Toolkit::TextInput::CURSOR_COLOR_PROPERTY, Property::VECTOR4, &TextInput::SetProperty, &TextInput::GetProperty ); + // [TextInput::HighlightInfo] ///////////////////////////////////////////////// @@ -279,9 +251,9 @@ Dali::Toolkit::TextInput TextInput::New() TextInputPtr textInput(new TextInput()); // Pass ownership to CustomActor via derived handle Dali::Toolkit::TextInput handle(*textInput); + handle.SetName( "TextInput"); textInput->Initialize(); - return handle; } @@ -794,9 +766,6 @@ void TextInput::SetBoundingRectangle( const Rect& boundingRectangle ) originY + boundingRectangle.height ); mBoundingRectangleWorldCoordinates = boundary; - - // Set Boundary for Popup so it keeps the Pop-up within the area also. - mPopupPanel.SetPopupBoundary( boundingRectangle ); } const Rect TextInput::GetBoundingRectangle() const @@ -1153,6 +1122,7 @@ void TextInput::CreateActiveLayer() { Actor self = Self(); mActiveLayer = Layer::New(); + mActiveLayer.SetName ( "ActiveLayerActor" ); mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER); mActiveLayer.SetParentOrigin( ParentOrigin::CENTER); @@ -1170,9 +1140,8 @@ void TextInput::OnInitialize() // Create 2 cursors (standard LTR and RTL cursor for when text can be added at // different positions depending on language) - Image mCursorImage = Image::New( DEFAULT_CURSOR ); - mCursor = CreateCursor( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER ); - mCursorRTL = CreateCursor( mCursorImage, DEFAULT_CURSOR_IMAGE_9_BORDER ); + mCursor = CreateCursor(DEFAULT_CURSOR_COLOR); + mCursorRTL = CreateCursor(DEFAULT_CURSOR_COLOR); Actor self = Self(); self.Add( mCursor ); @@ -1389,6 +1358,12 @@ void TextInput::OnDoubleTap(Dali::Actor actor, Dali::TapGesture tap) mTextLayoutInfo.mScrollOffset = mDisplayedTextView.GetScrollPosition(); ReturnClosestIndex( tap.localPoint, mCursorPosition ); + std::size_t start = 0; + std::size_t end = 0; + Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end ); + + mCursorPosition = end; // Ensure cursor is positioned at end of selected word + ImfManager imfManager = ImfManager::Get(); if ( imfManager ) { @@ -1396,14 +1371,20 @@ void TextInput::OnDoubleTap(Dali::Actor actor, Dali::TapGesture tap) imfManager.NotifyCursorPosition(); } - std::size_t start = 0; - std::size_t end = 0; - Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end ); - - SelectText( start, end ); + if ( !mStyledText.at(end-1).mText[0].IsWhiteSpace() ) + { + SelectText( start, end ); + ShowPopupCutCopyPaste(); + } + else + { + RemoveHighlight( false ); // Remove highlight but do not auto hide popup + HidePopup( false ); // Hide popup with setting to do auto show. + SetUpPopupSelection( false ); // Set to false so if nearest word is whitespace it will not show cut button. + ShowPopup(); + } } - // if no text but clipboard has content then show paste option - if ( ( mClipboard && mClipboard.NumberOfItems() ) || !mStyledText.empty() ) + else if ( mClipboard && mClipboard.NumberOfItems() ) { ShowPopupCutCopyPaste(); } @@ -1452,26 +1433,6 @@ void TextInput::OnTextTap(Dali::Actor actor, Dali::TapGesture tap) { // Set the initial cursor position in the tap point. ReturnClosestIndex(tap.localPoint, mCursorPosition ); - - // Create the grab handle. - // TODO Make this a re-usable function. - if ( IsGrabHandleEnabled() ) - { - const Vector3 cursorPosition = GetActualPositionFromCharacterPosition(mCursorPosition); - - CreateGrabHandle(); - - mActualGrabHandlePosition.x = cursorPosition.x; // Set grab handle to be at the cursor position - mActualGrabHandlePosition.y = cursorPosition.y; // Set grab handle to be at the cursor position - mGrabHandle.SetPosition( mActualGrabHandlePosition + UI_OFFSET ); - ShowGrabHandleAndSetVisibility( mIsGrabHandleInScrollArea ); - - } - - // Edit mode started after grab handle created to ensure the signal InputStarted is sent last. - // This is used to ensure if selecting text hides the grab handle then this code is run after grab handle is created, - // otherwise the Grab handle will be shown when selecting. - StartEditMode(); } } @@ -1525,6 +1486,9 @@ void TextInput::OnTextTap(Dali::Actor actor, Dali::TapGesture tap) } } + // Edit mode started after grab handle created to ensure the signal InputStarted is sent last. + // This is used to ensure if selecting text hides the grab handle then this code is run after grab handle is created, + // otherwise the Grab handle will be shown when selecting. if ( createGrabHandle && IsGrabHandleEnabled() ) { const Vector3 cursorPosition = GetActualPositionFromCharacterPosition(mCursorPosition); @@ -1543,6 +1507,12 @@ void TextInput::OnLongPress(Dali::Actor actor, Dali::LongPressGesture longPress) { DALI_LOG_INFO( gLogFilter, Debug::General, "OnLongPress\n" ); + // Ignore longpress if in selection mode already + if( mHighlightMeshActor ) + { + return; + } + if(longPress.state == Dali::Gesture::Started) { // Start edit mode on long press @@ -1579,15 +1549,18 @@ void TextInput::OnLongPress(Dali::Actor actor, Dali::LongPressGesture longPress) mTextLayoutInfo.mScrollOffset = mDisplayedTextView.GetScrollPosition(); ReturnClosestIndex( longPress.localPoint, mCursorPosition ); + std::size_t start = 0; + std::size_t end = 0; + Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end ); + + mCursorPosition = end; // Ensure cursor is positioned at end of selected word + ImfManager imfManager = ImfManager::Get(); if ( imfManager ) { imfManager.SetCursorPosition ( mCursorPosition ); imfManager.NotifyCursorPosition(); } - std::size_t start = 0; - std::size_t end = 0; - Dali::Toolkit::Internal::TextProcessor::FindNearestWord( mStyledText, mCursorPosition, start, end ); SelectText( start, end ); } @@ -1746,11 +1719,9 @@ bool TextInput::OnKeyDownEvent(const KeyEvent& event) { bool preEditFlagPreviouslySet( mPreEditFlag ); - if (mHighlightMeshActor) - { - // replaces highlighted text with new line - DeleteHighlightedText( false ); - } + // replaces highlighted text with new line + DeleteHighlightedText( false ); + mCursorPosition = mCursorPosition + InsertAt( Text( NEWLINE ), mCursorPosition, 0 ); // If we are in pre-edit mode then pressing enter will cause a commit. But the commit string does not include the @@ -1827,15 +1798,11 @@ bool TextInput::OnKeyDownEvent(const KeyEvent& event) // Some text may be selected, hiding keyboard causes an empty keystring to be sent, we don't want to delete highlight in this case if ( !keyString.empty() ) { - if ( mHighlightMeshActor ) - { - // replaces highlighted text with new character - DeleteHighlightedText( false ); - } - + // replaces highlighted text with new character + DeleteHighlightedText( false ); // Received key String - mCursorPosition = mCursorPosition + InsertAt( Text( keyString ), mCursorPosition, 0 ); + mCursorPosition += InsertAt( Text( keyString ), mCursorPosition, 0 ); update = true; EmitTextModified(); } @@ -1953,11 +1920,7 @@ void TextInput::ScrollTextViewToMakeCursorVisible( const Vector3& cursorPosition scrollOffset.x += cursorPosition.x; } - if( cursorPosition.y - cursorSize.height < 0.f ) - { - scrollOffset.y += ( cursorPosition.y - cursorSize.height ); - } - else if( cursorPosition.y > controlSize.height ) + if( cursorPosition.y - cursorSize.height < 0.f || cursorPosition.y > controlSize.height ) { scrollOffset.y += cursorPosition.y; } @@ -2082,6 +2045,7 @@ void TextInput::SetUpTouchEvents() void TextInput::CreateTextViewActor() { mDisplayedTextView = Toolkit::TextView::New(); + mDisplayedTextView.SetName( "DisplayedTextView "); mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled ); mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT); mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT); @@ -2269,7 +2233,7 @@ ImfManager::ImfCallbackData TextInput::ImfEventReceived( Dali::ImfManager& imfMa } else { - if( std::abs( imfEvent.cursorOffset ) < mCursorPosition ) + if( static_cast(std::abs( imfEvent.cursorOffset )) < mCursorPosition ) { toDelete = mCursorPosition + imfEvent.cursorOffset; } @@ -2585,7 +2549,7 @@ void TextInput::DeleteHighlightedText( bool inheritStyle ) { DALI_LOG_INFO( gLogFilter, Debug::General, "DeleteHighlightedText handlePosOne[%u] handlePosTwo[%u]\n", mSelectionHandleOnePosition, mSelectionHandleTwoPosition); - if(mHighlightMeshActor) + if( mHighlightMeshActor ) { mCursorPosition = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition ); @@ -2641,6 +2605,8 @@ void TextInput::DeleteHighlightedText( bool inheritStyle ) RemoveHighlight(); + EmitTextModified(); + if( inheritStyle ) { const TextStyle oldInputStyle( mInputStyle ); @@ -2826,24 +2792,14 @@ std::size_t TextInput::InsertAt( const Text& newText, const std::size_t insertio return insertedStringLength; } -ImageActor TextInput::CreateCursor( Image cursorImage, const Vector4& border ) +ImageActor TextInput::CreateCursor( const Vector4& color) { ImageActor cursor; - - if ( cursorImage ) - { - cursor = ImageActor::New( cursorImage ); - } - else - { - cursor = ImageActor::New( Image::New( DEFAULT_CURSOR ) ); - } - - cursor.SetStyle(ImageActor::STYLE_NINE_PATCH); - cursor.SetNinePatchBorder( border ); + cursor = CreateSolidColorActor(color); + cursor.SetName( "Cursor" ); cursor.SetParentOrigin(ParentOrigin::TOP_LEFT); - cursor.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER); + cursor.SetAnchorPoint(AnchorPoint::BOTTOM_LEFT); cursor.SetVisible(false); return cursor; @@ -2902,7 +2858,7 @@ void TextInput::DrawCursor(const std::size_t nthChar) { // Get height of cursor and set its size Size size( CURSOR_THICKNESS, 0.0f ); - if (!mTextLayoutInfo.mCharacterLayoutInfoTable.empty()) + if( !mTextLayoutInfo.mCharacterLayoutInfoTable.empty() ) { size.height = GetRowRectFromCharacterPosition( GetVisualPosition( mCursorPosition ) ).height; } @@ -2996,11 +2952,13 @@ void TextInput::CreateGrabHandle( Dali::Image image ) void TextInput::CreateGrabArea( Actor& parent ) { mGrabArea = Actor::New(); // Area that Grab handle responds to, larger than actual handle so easier to move + mGrabArea.SetName( "GrabArea" ); mGrabArea.SetPositionInheritanceMode( Dali::USE_PARENT_POSITION ); mGrabArea.ApplyConstraint( Constraint::New( Actor::SIZE, ParentSource( Actor::SIZE ), RelativeToConstraint( DEFAULT_GRAB_HANDLE_RELATIVE_SIZE ) ) ); // grab area to be larger than text actor mGrabArea.TouchedSignal().Connect(this,&TextInput::OnPressDown); mTapDetector.Attach( mGrabArea ); mPanGestureDetector.Attach( mGrabArea ); + mLongPressDetector.Attach( mGrabArea ); parent.Add(mGrabArea); } @@ -3510,7 +3468,7 @@ TextInput::HighlightInfo TextInput::CalculateHighlightInfo() // TODO: TextView should have a table of visual rows, and each character a reference to the row // that it resides on. That way this enumeration is not necessary. Vector2 min, max; - if(lastIt->mIsNewLineChar) + if(lastIt->mIsNewParagraphChar) { // If the last character is a new line, then to get the row rect, we need to scan from the character before the new line. lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 ); @@ -3557,7 +3515,7 @@ TextInput::HighlightInfo TextInput::CalculateHighlightInfo() { // finished selection. Vector2 min, max; - if(lastIt->mIsNewLineChar) + if(lastIt->mIsNewParagraphChar) { lastIt = std::max( mTextLayoutInfo.mCharacterLayoutInfoTable.begin(), lastIt - 1 ); } @@ -3856,7 +3814,7 @@ void TextInput::ShowPopupCutCopyPaste() ShowPopup(); } -void TextInput::SetUpPopupSelection() +void TextInput::SetUpPopupSelection( bool showCutButton ) { ClearPopup(); mPopupPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed @@ -3865,7 +3823,7 @@ void TextInput::SetUpPopupSelection() { mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelectAll, true ); mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsSelect, true ); - mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCut, true ); + mPopupPanel.TogglePopupButtonOnOff( TextInputPopup::ButtonsCut, showCutButton ); } // if clipboard has valid contents then offer paste option if( mClipboard && mClipboard.NumberOfItems() ) @@ -3923,7 +3881,7 @@ bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIn if( fabsf( closestYdifference - currentYdifference ) < CHARACTER_THRESHOLD ) { // ignore new line character. - if( !info.mIsNewLineChar ) + if( !info.mIsNewParagraphChar ) { matchedCharacters.push_back( info ); numberOfMatchedCharacters++; @@ -3937,7 +3895,7 @@ bool TextInput::ReturnClosestIndex(const Vector2& source, std::size_t& closestIn // and check if user is touching below previous line. const Toolkit::TextView::CharacterLayoutInfo& lastInfo( mTextLayoutInfo.mCharacterLayoutInfoTable[mTextLayoutInfo.mCharacterLayoutInfoTable.size() - 1] ); - if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewLineChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) ) + if( ( lastInfo.mIsVisible ) && ( lastInfo.mIsNewParagraphChar ) && ( sourceScrollOffset.y > lastInfo.mPosition.y ) ) { closestIndex = mTextLayoutInfo.mCharacterLayoutInfoTable.size(); } @@ -4195,7 +4153,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP } Toolkit::TextView::CharacterLayoutInfo info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ]; - if( ( visualCharacterPosition > 0 ) && info.mIsNewLineChar && !IsScrollEnabled() ) + if( ( visualCharacterPosition > 0 ) && info.mIsNewParagraphChar && !IsScrollEnabled() ) { // Prevents the cursor to exceed the boundary if the last visible character is a 'new line character' and the scroll is not enabled. const Vector3& size = GetControlSize(); @@ -4207,7 +4165,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP info = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterPosition ]; } - if(!info.mIsNewLineChar) + if(!info.mIsNewParagraphChar) { cursorPosition = PositionCursorAfterWordWrap( characterPosition ); // Get position of cursor/handles taking in account auto word wrap. } @@ -4255,7 +4213,7 @@ Vector3 TextInput::GetActualPositionFromCharacterPosition(std::size_t characterP // between RTL and LTR text... if(characterPosition != mTextLayoutInfo.mCharacterLogicalToVisualMap.size()) { - std::size_t visualCharacterAltPosition = mTextLayoutInfo.mCharacterLogicalToVisualMap[characterPosition] - 1; + std::size_t visualCharacterAltPosition = mTextLayoutInfo.mCharacterLogicalToVisualMap[characterPosition]; // VCC TODO: find why in the previous patch it was a -1 here. DALI_ASSERT_ALWAYS(visualCharacterAltPosition < mTextLayoutInfo.mCharacterLayoutInfoTable.size()); const Toolkit::TextView::CharacterLayoutInfo& infoAlt = mTextLayoutInfo.mCharacterLayoutInfoTable[ visualCharacterAltPosition ]; @@ -4407,7 +4365,7 @@ std::size_t TextInput::GetRowStartFromCharacterPosition(std::size_t logicalPosit { logicalPosition--; std::size_t visualPosition = GetVisualPosition(logicalPosition); - if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewLineChar) + if(mTextLayoutInfo.mCharacterLayoutInfoTable[visualPosition].mIsNewParagraphChar) { logicalPosition++; break; @@ -4477,7 +4435,7 @@ Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition, V --it; if( (it->mPosition.y < referenceLine) || - (it->mIsNewLineChar) || + (it->mIsNewParagraphChar) || (!it->mIsVisible) ) { break; @@ -4494,7 +4452,7 @@ Size TextInput::GetRowRectFromCharacterPosition(std::size_t characterPosition, V while(it != end) { if( (it->mPosition.y > referenceLine) || - (it->mIsNewLineChar) || + (it->mIsNewParagraphChar) || (!it->mIsVisible) ) { break; @@ -4598,16 +4556,7 @@ void TextInput::SelectText(std::size_t start, std::size_t end) // When replacing highlighted text keyboard should ignore current word at cursor hence notify keyboard that the cursor is at the start of the highlight. mSelectingText = true; - mCursorPosition = std::min( start, end ); // Set cursor position to start of highlighted text. - - ImfManager imfManager = ImfManager::Get(); - if ( imfManager ) - { - imfManager.SetCursorPosition ( mCursorPosition ); - imfManager.SetSurroundingText( GetText() ); - imfManager.NotifyCursorPosition(); - } - // As the imfManager has been notified of the new cursor position we do not need to reset the pre-edit as it will be updated instead. + std::size_t selectionStartPosition = std::min( start, end ); // Hide grab handle when selecting. ShowGrabHandleAndSetVisibility( false ); @@ -4621,7 +4570,7 @@ void TextInput::SelectText(std::size_t start, std::size_t end) UpdateHighlight(); const TextStyle oldInputStyle( mInputStyle ); - mInputStyle = GetStyleAt( mCursorPosition ); // Inherit style from selected position. + mInputStyle = GetStyleAt( selectionStartPosition ); // Inherit style from selected position. if( oldInputStyle != mInputStyle ) { @@ -4701,7 +4650,7 @@ void TextInput::KeyboardStatusChanged(bool keyboardShown) } // Removes highlight and resumes edit mode state -void TextInput::RemoveHighlight() +void TextInput::RemoveHighlight( bool hidePopup ) { DALI_LOG_INFO(gLogFilter, Debug::General, "RemoveHighlight\n"); @@ -4731,7 +4680,10 @@ void TextInput::RemoveHighlight() // NOTE: We cannot dereference mHighlightMesh, due // to a bug in how the scene-graph MeshRenderer uses the Mesh data incorrectly. - HidePopup(); + if ( hidePopup ) + { + HidePopup(); + } } mSelectionHandleOnePosition = 0; @@ -4754,7 +4706,6 @@ void TextInput::CreateHighlight() mHighlightMeshActor = MeshActor::New( mHighlightMesh ); mHighlightMeshActor.SetName( "HighlightMeshActor" ); - mHighlightMeshActor.SetInheritShaderEffect( false ); mHighlightMeshActor.SetParentOrigin( ParentOrigin::TOP_LEFT ); mHighlightMeshActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); mHighlightMeshActor.SetPosition( 0.0f, 0.0f, DISPLAYED_HIGHLIGHT_Z_OFFSET ); @@ -4820,6 +4771,7 @@ void TextInput::PasteText( const Text& text ) if( update ) { CursorUpdate(); + EmitTextModified(); } if( insertedStringLength < text.GetLength() ) @@ -5278,6 +5230,10 @@ void TextInput::SetProperty( BaseObject* object, Property::Index propertyIndex, textInputImpl.SetOffsetFromText( value.Get< Vector4 >() ); break; } + case Toolkit::TextInput::CURSOR_COLOR_PROPERTY: + { + textInputImpl.mCursor.SetColor( value.Get< Vector4 >() ); + } } } } @@ -5369,6 +5325,10 @@ Property::Value TextInput::GetProperty( BaseObject* object, Property::Index prop value = textInputImpl.GetOffsetFromText(); break; } + case Toolkit::TextInput::CURSOR_COLOR_PROPERTY: + { + value = textInputImpl.mCursor.GetCurrentColor(); + } } } return value;