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();
TextInputPtr textInput(new TextInput());
// Pass ownership to CustomActor via derived handle
Dali::Toolkit::TextInput handle(*textInput);
+ handle.SetName( "TextInput");
textInput->Initialize();
-
return handle;
}
mClipboard = Clipboard::Get(); // Store handle to clipboard
// Now in edit mode we can accept string to paste from clipboard
- if( Adaptor::IsAvailable() )
+ ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+ if ( notifier )
{
- ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
- if ( notifier )
- {
- notifier.ContentSelectedSignal().Connect( this, &TextInput::OnClipboardTextSelected );
- }
+ notifier.ContentSelectedSignal().Connect( this, &TextInput::OnClipboardTextSelected );
}
}
mClipboard.Reset();
// No longer in edit mode so do not want to receive string from clipboard
- if( Adaptor::IsAvailable() )
+ ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
+ if ( notifier )
{
- ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() );
- if ( notifier )
- {
- notifier.ContentSelectedSignal().Disconnect( this, &TextInput::OnClipboardTextSelected );
- }
- Clipboard clipboard = Clipboard::Get();
+ notifier.ContentSelectedSignal().Disconnect( this, &TextInput::OnClipboardTextSelected );
+ }
- if ( clipboard )
- {
- clipboard.HideClipboard();
- }
+ Clipboard clipboard = Clipboard::Get();
+ if ( clipboard )
+ {
+ clipboard.HideClipboard();
}
}
{
Actor self = Self();
mActiveLayer = Layer::New();
+ mActiveLayer.SetName ( "ActiveLayerActor" );
mActiveLayer.SetAnchorPoint( AnchorPoint::CENTER);
mActiveLayer.SetParentOrigin( ParentOrigin::CENTER);
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 )
{
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();
}
{
// 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();
}
}
}
}
+ // 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);
{
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
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 );
}
{
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
// 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();
}
void TextInput::CreateTextViewActor()
{
mDisplayedTextView = Toolkit::TextView::New();
+ mDisplayedTextView.SetName( "DisplayedTextView ");
mDisplayedTextView.SetMarkupProcessingEnabled( mMarkUpEnabled );
mDisplayedTextView.SetParentOrigin(ParentOrigin::TOP_LEFT);
mDisplayedTextView.SetAnchorPoint(AnchorPoint::TOP_LEFT);
{
DALI_LOG_INFO( gLogFilter, Debug::General, "DeleteHighlightedText handlePosOne[%u] handlePosTwo[%u]\n", mSelectionHandleOnePosition, mSelectionHandleTwoPosition);
- if(mHighlightMeshActor)
+ if( mHighlightMeshActor )
{
mCursorPosition = std::min( mSelectionHandleOnePosition, mSelectionHandleTwoPosition );
{
ImageActor cursor;
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;
{
// 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;
}
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<Vector3>( 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);
}
ShowPopup();
}
-void TextInput::SetUpPopupSelection()
+void TextInput::SetUpPopupSelection( bool showCutButton )
{
ClearPopup();
mPopupPanel.CreateOrderedListOfOptions(); // todo Move this so only run when order has changed
{
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() )
// 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 ];
// 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 );
UpdateHighlight();
const TextStyle oldInputStyle( mInputStyle );
- mInputStyle = GetStyleAt( mCursorPosition ); // Inherit style from selected position.
+ mInputStyle = GetStyleAt( selectionStartPosition ); // Inherit style from selected position.
if( oldInputStyle != mInputStyle )
{
}
// Removes highlight and resumes edit mode state
-void TextInput::RemoveHighlight()
+void TextInput::RemoveHighlight( bool hidePopup )
{
DALI_LOG_INFO(gLogFilter, Debug::General, "RemoveHighlight\n");
// 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;