X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-editor-impl.cpp;h=60db674603e7c54553c293f0316a0a19fe3466a1;hb=ee7b436210b09635d032b50eefecb7369be136e7;hp=5fac4ba437b7741585bbf6aa5449df0cd70ff477;hpb=8bb92d7d1170f2ddf59da60bd3588be601ef8cd2;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp index 5fac4ba..60db674 100644 --- a/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-editor-impl.cpp @@ -142,6 +142,8 @@ DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "renderingBackend", DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "maxLength", INTEGER, MAX_LENGTH ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectedTextStart", INTEGER, SELECTED_TEXT_START ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "selectedTextEnd", INTEGER, SELECTED_TEXT_END ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableEditing", BOOLEAN, ENABLE_EDITING ) +DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextEditor, "selectedText", STRING, SELECTED_TEXT ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED ) @@ -700,22 +702,23 @@ void TextEditor::SetProperty( BaseObject* object, Property::Index index, const P } case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: { - if( impl.mController ) - { - uint32_t start = static_cast(value.Get< int >()); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start ); - impl.SetTextSelectionRange( &start, nullptr ); - } + uint32_t start = static_cast(value.Get< int >()); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start ); + impl.SetTextSelectionRange( &start, nullptr ); break; } case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_END: { - if( impl.mController ) - { - uint32_t end = static_cast(value.Get< int >()); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end ); - impl.SetTextSelectionRange( nullptr, &end ); - } + uint32_t end = static_cast(value.Get< int >()); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end ); + impl.SetTextSelectionRange( nullptr, &end ); + break; + } + case Toolkit::DevelTextEditor::Property::ENABLE_EDITING: + { + const bool editable = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_EDITING %d\n", impl.mController.Get(), editable ); + impl.SetEditable( editable ); break; } } // switch @@ -1032,6 +1035,11 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind value = impl.mController->GetMaximumNumberOfCharacters(); break; } + case Toolkit::DevelTextEditor::Property::SELECTED_TEXT: + { + value = impl.mController->GetSelectedText( ); + break; + } case Toolkit::DevelTextEditor::Property::SELECTED_TEXT_START: { Uint32Pair range = impl.GetTextSelectionRange(); @@ -1044,12 +1052,44 @@ Property::Value TextEditor::GetProperty( BaseObject* object, Property::Index ind value = static_cast(range.second); break; } + case Toolkit::DevelTextEditor::Property::ENABLE_EDITING: + { + value = impl.IsEditable(); + break; + } } //switch } return value; } +void TextEditor::SelectWholeText() +{ + if( mController && mController->IsShowingRealText() ) + { + mController->SelectWholeText(); + SetKeyInputFocus(); + } +} + +void TextEditor::SelectNone() +{ + if( mController && mController->IsShowingRealText() ) + { + mController->SelectNone(); + } +} + +string TextEditor::GetSelectedText() const +{ + string selectedText = ""; + if( mController && mController->IsShowingRealText() ) + { + selectedText = mController->GetSelectedText( ); + } + return selectedText; +} + InputMethodContext TextEditor::GetInputMethodContext() { return mInputMethodContext; @@ -1367,7 +1407,7 @@ void TextEditor::RenderText( Text::Controller::UpdateTextType updateTextType ) void TextEditor::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnKeyInputFocusGained %p\n", mController.Get() ); - if ( mInputMethodContext ) + if ( mInputMethodContext && IsEditable() ) { mInputMethodContext.StatusChangedSignal().Connect( this, &TextEditor::KeyboardStatusChanged ); @@ -1421,7 +1461,7 @@ void TextEditor::OnKeyInputFocusLost() void TextEditor::OnTap( const TapGesture& gesture ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextEditor::OnTap %p\n", mController.Get() ); - if ( mInputMethodContext ) + if ( mInputMethodContext && IsEditable() ) { mInputMethodContext.Activate(); } @@ -1441,7 +1481,7 @@ void TextEditor::OnPan( const PanGesture& gesture ) void TextEditor::OnLongPress( const LongPressGesture& gesture ) { - if ( mInputMethodContext ) + if ( mInputMethodContext && IsEditable() ) { mInputMethodContext.Activate(); } @@ -1776,6 +1816,20 @@ void TextEditor::ApplyScrollPosition() } } +bool TextEditor::IsEditable() const +{ + return mController->IsEditable(); +} + +void TextEditor::SetEditable( bool editable ) +{ + mController->SetEditable(editable); + if ( mInputMethodContext && !editable ) + { + mInputMethodContext.Deactivate(); + } +} + TextEditor::TextEditor() : Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ), mAnimationPeriod( 0.0f, 0.0f ),