DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
END_TEST;
-}
\ No newline at end of file
+}
+
+int UtcDaliTextEditorEnableEditing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorEnableEditing ");
+
+ TextEditor textEditor = TextEditor::New();
+
+ application.GetScene().Add( textEditor );
+
+ textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+ textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ application.SendNotification();
+ application.Render();
+
+ textEditor.SetKeyInputFocus();
+ textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
+
+ textEditor.SetKeyInputFocus();
+ textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
+
+ END_TEST;
+}
END_TEST;
}
+
+int UtcDaliTextFieldEnableEditing(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldEnableEditing ");
+
+ TextField textField = TextField::New();
+
+ application.GetScene().Add( textField );
+
+ textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
+ textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
+ textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
+
+ // Avoid a crash when core load gl resources.
+ application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
+
+ application.SendNotification();
+ application.Render();
+
+ textField.SetKeyInputFocus();
+ textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
+
+
+ textField.SetKeyInputFocus();
+ textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
+ application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
+
+ END_TEST;
+}
* @details Name "selectedTextEnd", type Property::INTEGER.
*/
SELECTED_TEXT_END,
+
+ /**
+ * @brief The Editable state of control.
+ * @details Name "editable", type Property::BOOL.
+ */
+ ENABLE_EDITING,
};
} // namespace Property
*/
SELECTED_TEXT_END,
-};
+ /**
+ * @brief The Editable state of control.
+ * @details Name "editable", type Property::BOOL.
+ */
+ ENABLE_EDITING,
+};
} // namespace Property
/**
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_SIGNAL_REGISTRATION( Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION( Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED )
}
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
} // texteditor
}
value = static_cast<int>(range.second);
break;
}
+ case Toolkit::DevelTextEditor::Property::ENABLE_EDITING:
+ {
+ value = impl.IsEditable();
+ break;
+ }
} //switch
}
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 );
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();
}
void TextEditor::OnLongPress( const LongPressGesture& gesture )
{
- if ( mInputMethodContext )
+ if ( mInputMethodContext && IsEditable() )
{
mInputMethodContext.Activate();
}
}
}
+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 ),
*/
void AddDecoration( Actor& actor, bool needsClipping ) override;
-
// From SelectableControlInterface
public:
/**
*/
Uint32Pair GetTextSelectionRange() const override;
+ /**
+ * @copydoc Text::EditableControlInterface::IsEditable()
+ */
+ bool IsEditable() const override;
+
+ /**
+ * @copydoc Text::EditableControlInterface::SetEditable()
+ */
+ void SetEditable( bool editable ) override;
+
private: // Implementation
/**
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 )
}
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
} // textfield
}
value = static_cast<int>(range.second);
break;
}
+ case Toolkit::DevelTextField::Property::ENABLE_EDITING:
+ {
+ value = impl.IsEditable();
+ break;
+ }
} //switch
}
void TextField::OnKeyInputFocusGained()
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "TextField::OnKeyInputFocusGained %p\n", mController.Get() );
- if ( mInputMethodContext )
+ if ( mInputMethodContext && IsEditable() )
{
mInputMethodContext.ApplyOptions( mInputMethodOptions );
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();
}
void TextField::OnLongPress( const LongPressGesture& gesture )
{
- if ( mInputMethodContext )
+ if ( mInputMethodContext && IsEditable() )
{
mInputMethodContext.Activate();
}
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() );
*/
void AddDecoration( Actor& actor, bool needsClipping ) override;
-
// From SelectableControlInterface
public:
/**
*/
Uint32Pair GetTextSelectionRange() const override;
+ /**
+ * @copydoc Text::EditableControlInterface::IsEditable()
+ */
+ bool IsEditable() const override;
+
+ /**
+ * @copydoc Text::EditableControlInterface::SetEditable()
+ */
+ void SetEditable( bool editable ) override;
+
private: // Implementation
/**
mHorizontalScrollingEnabled( false ),
mVerticalScrollingEnabled( false ),
mSmoothHandlePanEnabled( false ),
- mIsHighlightBoxActive( false )
+ mIsHighlightBoxActive( false ),
+ mHidePrimaryCursorAndGrabHandle( false )
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
if( mPrimaryCursor )
{
const CursorImpl& cursor = mCursor[PRIMARY_CURSOR];
- mPrimaryCursorVisible = ( ( mControlSize.width - ( cursor.position.x + mCursorWidth ) > -Math::MACHINE_EPSILON_1000 ) &&
+ mPrimaryCursorVisible = (!mHidePrimaryCursorAndGrabHandle) && ( ( mControlSize.width - ( cursor.position.x + mCursorWidth ) > -Math::MACHINE_EPSILON_1000 ) &&
( cursor.position.x > -Math::MACHINE_EPSILON_1000 ) &&
( mControlSize.height - ( cursor.position.y + cursor.cursorHeight ) > -Math::MACHINE_EPSILON_1000 ) &&
( cursor.position.y > -Math::MACHINE_EPSILON_1000 ) );
grabHandle.verticallyVisible = ( ( ( mControlSize.height - grabHandle.lineHeight ) - grabHandle.position.y > -Math::MACHINE_EPSILON_1000 ) &&
( grabHandle.position.y > -Math::MACHINE_EPSILON_1000 ) );
- const bool isVisible = grabHandle.horizontallyVisible && grabHandle.verticallyVisible;
+ const bool isVisible = grabHandle.horizontallyVisible && grabHandle.verticallyVisible && (!mHidePrimaryCursorAndGrabHandle);
if( isVisible )
{
CreateGrabHandle();
bool mVerticalScrollingEnabled : 1; ///< Whether the vertical scrolling is enabled.
bool mSmoothHandlePanEnabled : 1; ///< Whether to pan smoothly the handles.
bool mIsHighlightBoxActive : 1; ///< Whether the highlight box is active.
+ bool mHidePrimaryCursorAndGrabHandle : 1; ///< Whether the primary cursor and grab are hidden always.
};
DecoratorPtr Decorator::New( ControllerInterface& controller,
return static_cast<int>( mImpl->mCursorWidth );
}
+void Decorator::SetEditable( bool editable )
+{
+ mImpl->mHidePrimaryCursorAndGrabHandle = !editable;
+ mImpl->Relayout( mImpl->mControlSize );
+}
/** Handles **/
void Decorator::SetHandleActive( HandleType handleType, bool active )
*/
void SetScrollSpeed( float speed );
+ /**
+ * @brief Sets Editable mode decoration.
+ *
+ * If this set to false, Primary cursor and grab will always be hidden.
+ *
+ * @param[in] isEditable enable or disable Editing.
+ */
+ void SetEditable( bool isEditable );
+
/**
* @brief Retrieves the scroll speed.
*
mIsPlaceholderElideEnabled( false ),
mPlaceholderEllipsisFlag( false ),
mShiftSelectionFlag( true ),
- mUpdateAlignment( false )
+ mUpdateAlignment( false ),
+ mEditingEnabled( true )
{
}
return range;
}
+bool Controller::Impl::IsEditable() const
+{
+ return mEventData && mEventData->mEditingEnabled;
+}
+
+void Controller::Impl::SetEditable( bool editable )
+{
+ if( mEventData)
+ {
+ mEventData->mEditingEnabled = editable;
+ }
+}
+
void Controller::Impl::RetrieveSelection( std::string& selectedText, bool deleteAfterRetrieval )
{
if( mEventData->mLeftSelectionPosition == mEventData->mRightSelectionPosition )
* If EDITING_WITH_POPUP : SELECT & SELECT_ALL
*/
+ bool isEditable = IsEditable();
TextSelectionPopup::Buttons buttonsToShow = TextSelectionPopup::NONE;
if( EventData::SELECTING == mEventData->mState )
{
- buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::CUT | TextSelectionPopup::COPY );
+ buttonsToShow = TextSelectionPopup::Buttons( TextSelectionPopup::COPY );
+ if(isEditable)
+ {
+ buttonsToShow = TextSelectionPopup::Buttons( buttonsToShow | TextSelectionPopup::CUT );
+ }
if( !IsClipboardEmpty() )
{
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ if(isEditable)
+ {
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ }
buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
}
if( !IsClipboardEmpty() )
{
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ if(isEditable)
+ {
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ }
buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
}
}
{
if ( !IsClipboardEmpty() )
{
- buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ if(isEditable)
+ {
+ buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::PASTE ) );
+ }
buttonsToShow = TextSelectionPopup::Buttons ( ( buttonsToShow | TextSelectionPopup::CLIPBOARD ) );
}
}
bool mPlaceholderEllipsisFlag : 1; ///< True if the text controller sets the placeholder ellipsis.
bool mShiftSelectionFlag : 1; ///< True if the text selection using Shift key is enabled.
bool mUpdateAlignment : 1; ///< True if the whole text needs to be full aligned..
+ bool mEditingEnabled : 1; ///< True if the editing is enabled, false otherwise.
};
struct ModifyEvent
Uint32Pair GetTextSelectionRange() const;
/**
+ * @copydoc Text::EditableControlInterface::IsEditable()
+ */
+ bool IsEditable() const;
+
+ /**
+ * @copydoc Text::EditableControlInterface::SetEditable()
+ */
+ void SetEditable( bool editable );
+
+ /**
* @brief Retrieves the selected text. It removes the text if the @p deleteAfterRetrieval parameter is @e true.
*
* @param[out] selectedText The selected text encoded in utf8.
else
{
DALI_LOG_INFO( gLogFilter, Debug::Verbose, "Controller::KeyEvent %p keyString %s\n", this, keyString.c_str() );
+ if (!IsEditable()) return false;
if( !keyString.empty() )
{
}
}
+bool Controller::IsEditable() const
+{
+ return mImpl->IsEditable();
+}
+
+void Controller::SetEditable( bool editable )
+{
+ mImpl->SetEditable( editable );
+ if(mImpl->mEventData && mImpl->mEventData->mDecorator)
+ {
+ mImpl->mEventData->mDecorator->SetEditable( editable );
+ }
+}
+
void Controller::DecorationEvent( HandleType handleType, HandleState state, float x, float y )
{
DALI_ASSERT_DEBUG( mImpl->mEventData && "Unexpected DecorationEvent" );
{
case Toolkit::TextSelectionPopup::CUT:
{
+ if (!IsEditable()) return;
mImpl->SendSelectionToClipboard( true ); // Synchronous call to modify text
mImpl->mOperationsPending = ALL_OPERATIONS;
return;
}
+ if (!IsEditable()) return;
+
mImpl->mEventData->mCheckScrollAmount = true;
// The natural size needs to be re-calculated.
return removed;
}
+ if (!IsEditable()) return false;
+
// InputMethodContext is no longer handling key-events
mImpl->ClearPreEditFlag();
Uint32Pair GetTextSelectionRange() const;
/**
+ * @copydoc Text::EditableControlInterface::IsEditable()
+ */
+ virtual bool IsEditable() const;
+
+ /**
+ * @copydoc Text::EditableControlInterface::SetEditable()
+ */
+ virtual void SetEditable( bool editable );
+
+ /**
* @brief Event received from input method context
*
* @param[in] inputMethodContext The input method context.
* @param[in] needsClipping Whether the actor needs clipping.
*/
virtual void AddDecoration( Actor& actor, bool needsClipping ) = 0;
+
+ /**
+ * @brief Editable status (on/off).
+ *
+ * @return true if it can be edit, else false.
+ */
+ virtual bool IsEditable() const = 0;
+
+ /**
+ * @brief Change the editable status (on/off) .
+ *
+ * @param[in] editable The editable status.
+ */
+ virtual void SetEditable( bool editable ) = 0;
};
} // namespace Text