/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
+const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
+ DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
END_TEST;
}
editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
+ Property::Map imagePropertyMap;
+ imagePropertyMap["type"] = "BufferImage";
+ imagePropertyMap["width"] = 40;
+ imagePropertyMap["height"] = 40;
+
+ editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
+ editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
+ editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
+ editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
+
editor.SetSize( 30.f, 500.f );
editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
application.SendNotification();
application.Render();
+ // Tap first to get the focus.
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // Double tap to select a word and create the selection handles.
+ application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
+ application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ touchPos = Vector2( 10.0f, 50.0f );
+
+ // Touch the left selection handle to set it as pressed.
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointDownInside( touchPos ) );
+ application.ProcessEvent( event );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
+ // drag the left selection handle right
+ SendPan(application, Gesture::Possible, touchPos);
+ SendPan(application, Gesture::Started, touchPos);
+ touchPos.x += 5.0f;
+ Wait(application, 100);
+
+ for(int i = 0;i<20;i++)
+ {
+ SendPan(application, Gesture::Continuing, touchPos);
+ touchPos.x += 5.0f;
+ Wait(application);
+ }
+
+ SendPan(application, Gesture::Finished, touchPos);
+ Wait(application);
+
+ // Release the left selection handle.
+ event = Dali::Integration::TouchEvent();
+ event.AddPoint( GetPointUpInside( touchPos ) );
+ application.ProcessEvent( event );
+
+ // Render and notify
+ application.SendNotification();
+ application.Render();
+
END_TEST;
}
-
int utcDaliTextEditorUnderPropertyStringP(void)
{
ToolkitTestApplication application;
END_TEST;
}
+
+int UtcDaliTextEditorEnableGrabHandleProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
+
+ TextEditor editor = TextEditor::New();
+ DALI_TEST_CHECK( editor );
+ editor.SetSize( 300.f, 50.f );
+ editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( editor );
+
+ application.SendNotification();
+ application.Render();
+
+ // The default value of ENABLE_GRAB_HANDLE is 'true'.
+ DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
+
+ // Check the enable grab handle property
+ editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
+ DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
+const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
+ DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
END_TEST;
}
application.SendNotification();
application.Render();
-
// Tap first to get the focus.
application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
END_TEST;
}
+
+int UtcDaliTextFieldEnableGrabHandleProperty(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
+
+ TextField field = TextField::New();
+ DALI_TEST_CHECK( field );
+ field.SetSize( 300.f, 50.f );
+ field.SetParentOrigin( ParentOrigin::TOP_LEFT );
+ field.SetAnchorPoint( AnchorPoint::TOP_LEFT );
+ Stage::GetCurrent().Add( field );
+
+ application.SendNotification();
+ application.Render();
+
+ // The default value of ENABLE_GRAB_HANDLE is 'true'.
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
+
+ // Check the enable grab handle property
+ field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
+ DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
+
+ application.SendNotification();
+ application.Render();
+
+ END_TEST;
+}
* @brief Enables Text selection using Shift key.
* @details Name "enableShiftSelection", type Property::BOOLEAN.
*/
- ENABLE_SHIFT_SELECTION
+ ENABLE_SHIFT_SELECTION,
+
+ /**
+ * @brief Enables the grab handles for text selection.
+ * @details Name "enableGrabHandle", type Property::BOOLEAN.
+ * @note The default value is true, which means the grab handles are enabled by default.
+ */
+ ENABLE_GRAB_HANDLE
};
} // namespace Property
* @brief Enables Text selection using Shift key.
* @details Name "enableShiftSelection", type Property::BOOLEAN.
*/
- ENABLE_SHIFT_SELECTION = ELLIPSIS + 1
+ ENABLE_SHIFT_SELECTION = ELLIPSIS + 1,
+
+ /**
+ * @brief Enables the grab handles for text selection.
+ * @details Name "enableGrabHandle", type Property::BOOLEAN.
+ * @note The default value is true, which means the grab handles are enabled by default.
+ */
+ ENABLE_GRAB_HANDLE = ELLIPSIS + 2
};
} // namespace Property
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderText", STRING, PLACEHOLDER_TEXT )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "placeholderTextColor", VECTOR4, PLACEHOLDER_TEXT_COLOR )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextEditor, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
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_GRAB_HANDLE:
+ {
+ if( impl.mController )
+ {
+ const bool grabHandleEnabled = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextEditor %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled );
+
+ impl.mController->SetGrabHandleEnabled( grabHandleEnabled );
+ }
+ break;
+ }
} // switch
} // texteditor
}
}
break;
}
+ case Toolkit::DevelTextEditor::Property::ENABLE_GRAB_HANDLE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsGrabHandleEnabled();
+ }
+ break;
+ }
} //switch
}
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "placeholder", MAP, PLACEHOLDER )
DALI_PROPERTY_REGISTRATION( Toolkit, TextField, "ellipsis", BOOLEAN, ELLIPSIS )
DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableShiftSelection", BOOLEAN, ENABLE_SHIFT_SELECTION )
+DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, TextField, "enableGrabHandle", BOOLEAN, ENABLE_GRAB_HANDLE )
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_GRAB_HANDLE:
+ {
+ if( impl.mController )
+ {
+ const bool grabHandleEnabled = value.Get<bool>();
+ DALI_LOG_INFO( gLogFilter, Debug::General, "TextField %p ENABLE_GRAB_HANDLE %d\n", impl.mController.Get(), grabHandleEnabled );
+
+ impl.mController->SetGrabHandleEnabled( grabHandleEnabled );
+ }
+ break;
+ }
} // switch
} // textfield
}
}
break;
}
+ case Toolkit::DevelTextField::Property::ENABLE_GRAB_HANDLE:
+ {
+ if( impl.mController )
+ {
+ value = impl.mController->IsGrabHandleEnabled();
+ }
+ break;
+ }
} //switch
}
mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
mEventData->mDecorator->StopCursorBlink();
mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
+ if ( mEventData->mGrabHandleEnabled )
+ {
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
+ }
mEventData->mDecorator->SetHighlightActive( true );
if( mEventData->mGrabHandlePopupEnabled )
{
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHighlightActive( false );
}
- else
+ else if ( mEventData->mGrabHandleEnabled )
{
mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
}
mEventData->mDecorator->StartCursorBlink();
}
// Grab handle is not shown until a tap is received whilst EDITING
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ if ( mEventData->mGrabHandleEnabled )
+ {
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ }
mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHighlightActive( false );
mEventData->mDecorator->SetActiveCursor( ACTIVE_CURSOR_NONE );
mEventData->mDecorator->StopCursorBlink();
mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, false );
- mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
- mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
+ if ( mEventData->mGrabHandleEnabled )
+ {
+ mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, true );
+ mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, true );
+ }
mEventData->mDecorator->SetHighlightActive( true );
if( mEventData->mGrabHandlePopupEnabled )
{
{
mEventData->mDecorator->StartCursorBlink();
}
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ if ( mEventData->mGrabHandleEnabled )
+ {
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ }
mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHighlightActive( false );
mEventData->mDecorator->StartCursorBlink();
}
- mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ if ( mEventData->mGrabHandleEnabled )
+ {
+ mEventData->mDecorator->SetHandleActive( GRAB_HANDLE, true );
+ }
mEventData->mDecorator->SetHandleActive( LEFT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHandleActive( RIGHT_SELECTION_HANDLE, false );
mEventData->mDecorator->SetHighlightActive( false );
return mImpl->mEventData->mShiftSelectionFlag;
}
+void Controller::SetGrabHandleEnabled( bool enabled )
+{
+ mImpl->mEventData->mGrabHandleEnabled = enabled;
+}
+
+bool Controller::IsGrabHandleEnabled() const
+{
+ return mImpl->mEventData->mGrabHandleEnabled;
+}
+
// public : Update
void Controller::SetText( const std::string& text )
*/
bool IsShiftSelectionEnabled() const;
+ /**
+ * @brief Enable or disable the grab handles for text selection.
+ *
+ * @param[in] enabled Whether to enable the grab handles
+ */
+ void SetGrabHandleEnabled( bool enabled );
+
+ /**
+ * @brief Returns whether the grab handles are enabled.
+ *
+ * @return True if the grab handles are enabled
+ */
+ bool IsGrabHandleEnabled() const;
+
/**
* @brief Sets input type to password
*