X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Ftext-controls%2Ftext-field-impl.cpp;h=a85a3424b3b45fd3ecda13355fdb70280c04db63;hb=e1252758509d9c829eea22158f0310f59706039a;hp=442c7a4680d721fc514ec178427ae568197cd8c6;hpb=4b6e68d1df075ead5c35eaa36c8bd2ede20ddb92;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp index 442c7a4..a85a342 100644 --- a/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp +++ b/dali-toolkit/internal/controls/text-controls/text-field-impl.cpp @@ -38,8 +38,6 @@ #include #include #include -#include -#include #include #include #include @@ -139,6 +137,7 @@ DALI_DEVEL_PROPERTY_REGISTRATION_READ_ONLY( Toolkit, TextField, "selectedText", DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "renderingBackend", INTEGER, RENDERING_BACKEND ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextStart", INTEGER, SELECTED_TEXT_START ) DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "selectedTextEnd", INTEGER, SELECTED_TEXT_END ) +DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableEditing", BOOLEAN, ENABLE_EDITING ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED ) DALI_SIGNAL_REGISTRATION( Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED ) @@ -715,22 +714,23 @@ void TextField::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::DevelTextField::Property::SELECTED_TEXT_START: { - if( impl.mController ) - { - uint32_t start = static_cast(value.Get< int >()); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %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, "TextField %p SELECTED_TEXT_START %d\n", impl.mController.Get(), start ); + impl.SetTextSelectionRange( &start, nullptr ); break; } case Toolkit::DevelTextField::Property::SELECTED_TEXT_END: { - if( impl.mController ) - { - uint32_t end = static_cast(value.Get< int >()); - DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %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, "TextField %p SELECTED_TEXT_END %d\n", impl.mController.Get(), end ); + impl.SetTextSelectionRange( nullptr, &end ); + break; + } + case Toolkit::DevelTextField::Property::ENABLE_EDITING: + { + const bool editable = value.Get< bool >(); + DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_EDITING %d\n", impl.mController.Get(), editable ); + impl.SetEditable( editable ); break; } } // switch @@ -1068,6 +1068,11 @@ Property::Value TextField::GetProperty( BaseObject* object, Property::Index inde value = static_cast(range.second); break; } + case Toolkit::DevelTextField::Property::ENABLE_EDITING: + { + value = impl.IsEditable(); + break; + } } //switch } @@ -1078,7 +1083,7 @@ void TextField::SelectWholeText() { if( mController && mController->IsShowingRealText() ) { - mController->SelectEvent( 0.f, 0.f, SelectionType::ALL ); + mController->SelectWholeText(); SetKeyInputFocus(); } } @@ -1087,11 +1092,20 @@ void TextField::SelectNone() { if( mController && mController->IsShowingRealText() ) { - mController->SelectEvent( 0.f, 0.f, SelectionType::NONE ); - SetKeyInputFocus(); + mController->SelectNone(); } } +string TextField::GetSelectedText() const +{ + string selectedText = ""; + if( mController && mController->IsShowingRealText() ) + { + selectedText = mController->GetSelectedText( ); + } + return selectedText; +} + void TextField::SetTextSelectionRange(const uint32_t *start, const uint32_t *end) { if( mController && mController->IsShowingRealText() ) @@ -1460,7 +1474,7 @@ void TextField::RenderText( Text::Controller::UpdateTextType updateTextType ) void TextField::OnKeyInputFocusGained() { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() ); - if( mInputMethodContext ) + if ( mInputMethodContext && IsEditable() ) { mInputMethodContext.ApplyOptions( mInputMethodOptions ); @@ -1474,30 +1488,13 @@ void TextField::OnKeyInputFocusGained() // When window gain lost focus, the inputMethodContext is deactivated. Thus when window gain focus again, the inputMethodContext must be activated. mInputMethodContext.SetRestoreAfterFocusLost( true ); } - ClipboardEventNotifier notifier( ClipboardEventNotifier::Get() ); - if( notifier ) + + if ( notifier ) { notifier.ContentSelectedSignal().Connect( this, &TextField::OnClipboardTextSelected ); } - Toolkit::Control control = Toolkit::Control::DownCast( Self() ); - Internal::Control& controlImpl = GetImplementation( control ); - Internal::Control::Impl& controlDataImpl = Internal::Control::Impl::Get( controlImpl ); - bool enableAutofill = controlDataImpl.IsAutofillEnabled(); - if( enableAutofill ) - { - Toolkit::AutofillContainer container = controlDataImpl.GetAutofillContainer(); - container.SetFocusedControl( control ); - - Internal::AutofillContainer& containerImpl = GetImpl( container ); - Dali::AutofillGroup containerGroup = containerImpl.GetAutofillGroup(); - if( containerGroup != nullptr ) - { - containerGroup.RequestAuthentication(); - } - - } mController->KeyboardFocusGainEvent(); // Called in the case of no virtual keyboard to trigger this event EmitKeyInputFocusSignal( true ); // Calls back into the Control hence done last. @@ -1532,7 +1529,7 @@ void TextField::OnKeyInputFocusLost() void TextField::OnTap( const TapGesture& gesture ) { DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnTap %p\n", mController.Get() ); - if ( mInputMethodContext ) + if ( mInputMethodContext && IsEditable() ) { mInputMethodContext.Activate(); } @@ -1552,7 +1549,7 @@ void TextField::OnPan( const PanGesture& gesture ) void TextField::OnLongPress( const LongPressGesture& gesture ) { - if ( mInputMethodContext ) + if ( mInputMethodContext && IsEditable() ) { mInputMethodContext.Activate(); } @@ -1592,6 +1589,20 @@ void TextField::RequestTextRelayout() RelayoutRequest(); } +bool TextField::IsEditable() const +{ + return mController->IsEditable(); +} + +void TextField::SetEditable( bool editable ) +{ + mController->SetEditable(editable); + if ( mInputMethodContext && !editable ) + { + mInputMethodContext.Deactivate(); + } +} + void TextField::TextChanged() { Dali::Toolkit::TextField handle( GetOwner() ); @@ -1755,7 +1766,7 @@ void TextField::OnSceneConnection( int depth ) bool TextField::OnTouched( Actor actor, const TouchEvent& touch ) { - return true; + return false; } void TextField::OnIdleSignal()