// Sets some text.
controller->SetText( "Hello world" );
+ // When the TextSelectionPopup is active, the controller has focus.
+ controller->KeyboardFocusGainEvent();
+
// Select the whole text.
button = PushButton::DownCast( textPopup.FindChildByName( OPTION_SELECT_ALL ) );
DALI_TEST_CHECK( button );
}
- bool SetSize(const Vector2& size)
+ bool SetSize(Vector2 size)
{
mSize = size;
// For negative test
return true;
}
- const Vector2& GetSize()
+ Vector2 GetSize() const
{
- mSize = Vector2(200, 200);
- return mSize;
+ return Vector2(200, 200);
}
bool SetViewBox(const Vector2& viewBox)
return Internal::Adaptor::GetImplementation(*this).RemoveAllDrawables();
}
-bool CanvasRenderer::SetSize(const Vector2& size)
+bool CanvasRenderer::SetSize(Vector2 size)
{
return Internal::Adaptor::GetImplementation(*this).SetSize(size);
}
-const Vector2& CanvasRenderer::GetSize()
+Vector2 CanvasRenderer::GetSize() const
{
return Internal::Adaptor::GetImplementation(*this).GetSize();
}
END_TEST;
}
+int UtcDaliTextEditorSelectText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextEditorSelectText ");
+
+ 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();
+
+ DevelTextEditor::SelectText( textEditor ,0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ // Nothing is selected
+ std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+ textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
+
+ application.SendNotification();
+ application.Render();
+
+ DevelTextEditor::SelectText( textEditor, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+ // world is selected
+ DevelTextEditor::SelectText( textEditor, 6, 11 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliTextEditorSelectNone(void)
{
ToolkitTestApplication application;
textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
application.SendNotification();
application.Render();
+ textEditor.SetKeyInputFocus();
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
END_TEST;
}
+int UtcDaliTextFieldPlaceholderCoverage(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ TextField fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderFontFamily() coverage.
+ Property::Map fontFamilyMap;
+ fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontSize coverage.
+ Property::Map fontSizeMap;
+ fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontWeight coverage.
+ Property::Map fontStyleWeightMap;
+ Property::Map fontStyleWeightPropertyMap;
+ fontStyleWeightPropertyMap.Insert("weight", "bold");
+ fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontWidth coverage.
+ Property::Map fontStyleWidthMap;
+ Property::Map fontStyleWidthPropertyMap;
+ fontStyleWidthPropertyMap.Insert("width", "expanded");
+ fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
+
+ // mPlaceholderFont is created only once, so create a new control for coverage.
+ fieldForCoverage = TextField::New();
+ DALI_TEST_CHECK(fieldForCoverage);
+ application.GetScene().Add(fieldForCoverage);
+
+ // for SetPlaceholderTextFontSlant coverage.
+ Property::Map fontStyleSlantMap;
+ Property::Map fontStyleSlantPropertyMap;
+ fontStyleSlantPropertyMap.Insert("slant", "italic");
+ fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
+ fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
+
+ END_TEST;
+}
+
int UtcDaliTextFieldSetPaddingProperty(void)
{
ToolkitTestApplication application;
END_TEST;
}
+int UtcDaliTextFieldSelectText(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliTextFieldSelectText ");
+
+ 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();
+
+ DevelTextField::SelectText( textField, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ // Nothing is selected
+ std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
+
+ textField.SetProperty( TextField::Property::TEXT, "Hello world" );
+
+ application.SendNotification();
+ application.Render();
+
+ // Hello is selected
+ DevelTextField::SelectText( textField, 0, 5 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
+
+ // world is selected
+ DevelTextField::SelectText( textField, 6, 11 );
+
+ application.SendNotification();
+ application.Render();
+
+ selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
+ DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
+
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
+ DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
+
+ END_TEST;
+}
+
int UtcDaliTextFieldSelectNone(void)
{
ToolkitTestApplication application;
textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
application.SendNotification();
application.Render();
+ textField.SetKeyInputFocus();
application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
GetImpl(textEditor).SelectNone();
}
+void SelectText(TextEditor textEditor, const uint32_t start, const uint32_t end)
+{
+ GetImpl(textEditor).SelectText(start, end);
+}
+
void ScrollBy(TextEditor textEditor, Vector2 scroll)
{
GetImpl(textEditor).ScrollBy(scroll);
DALI_TOOLKIT_API void SelectNone(TextEditor textEditor);
/**
+ * @brief Select the text from start index to end index of TextEditor.
+ * @note
+ * The selection index is based on the cursor index.
+ *
+ * text H e l l o
+ * index 0 1 2 3 4 5
+ * if textEditor.SelectText(1, 4); is executed, "ell" is selected.
+ *
+ * @param[in] textEditor The instance of TextEditor.
+ * @param[in] start The start index of the text to select. (The starting point of start index is 0.)
+ * @param[in] end The end index of the text to select. (If end index > text's length, the end index is set to the length of the text.)
+ */
+DALI_TOOLKIT_API void SelectText(TextEditor textEditor, const uint32_t start, const uint32_t end);
+
+/**
* @brief Scroll the TextEditor by specific amount.
*
* @param[in] textEditor The instance of TextEditor.
GetImpl(textField).SelectNone();
}
+void SelectText(TextField textField, const uint32_t start, const uint32_t end)
+{
+ GetImpl(textField).SelectText(start, end);
+}
+
} // namespace DevelTextField
} // namespace Toolkit
*/
DALI_TOOLKIT_API void SelectNone(TextField textField);
+/**
+ * @brief Select the text from start index to end index of TextField.
+ * @note
+ * The selection index is based on the cursor index.
+ *
+ * text H e l l o
+ * index 0 1 2 3 4 5
+ * if textField.SelectText(1, 4); is executed, "ell" is selected.
+ *
+ * @param[in] textField The instance of TextField.
+ * @param[in] start The start index of the text to select. (The starting point of start index is 0.)
+ * @param[in] end The end index of the text to select. (If end index > text's length, the end index is set to the length of the text.)
+ */
+DALI_TOOLKIT_API void SelectText(TextField textField, const uint32_t start, const uint32_t end);
+
} // namespace DevelTextField
} // namespace Toolkit
OPACITY = Dali::Toolkit::Visual::Property::OPACITY,
/**
- * @brief The fitting mode of the visual
+ * @brief The fitting mode of the visual.
* @details Name "fittingMode", type FittingMode (Property::INTEGER) or Property::STRING.
* @see DevelVisual::FittingMode
* @note The default is defined by the type of visual (if it's suitable to be stretched or not).
VISUAL_FITTING_MODE = OPACITY + 1,
/**
- * @brief The radius for the rounded corners of the visual
+ * @brief The radius for the rounded corners of the visual.
* @details Name "cornerRadius", type Property::FLOAT or Prooperty::VECTOR4, animatable
* @note By default, it is Vector::ZERO.
* @note Only Property::Vector4 can be animated.
* @note Each radius will clamp internally to the half of smaller of the visual width and visual height.
- * @note Their may exist some alias when you use it as ClippingMode::CLIP_CHILDREN
+ * @note Their may exist some alias when you use it as ClippingMode::CLIP_CHILDREN.
* @note Radius value are used in clockwise order from top-left-corner to bottom-left-corner.
* When radius is Vector4(x, y, z, w)
* x y
CORNER_RADIUS = OPACITY + 2,
/**
- * @brief Whether the corner radius value is relative (percentage [0.0f to 1.0f] of the visual size) or absolute (in world units).
+ * @brief Whether the corner radius value is relative (percentage [0.0f to 0.5f] of the visual size) or absolute (in world units).
* @details Name "cornerRadiusPolicy", type Property::INTEGER.
* @see Policy::Type
* @note By default, it is ABSOLUTE to the visual's size.
CORNER_RADIUS_POLICY = OPACITY + 3,
/**
- * @brief The width for the borderline of the visual
+ * @brief The width for the borderline of the visual.
* @details Name "borderlineWidth", type Property::FLOAT, animatable
* @note Optional. Default value is 0.0f.
*/
BORDERLINE_WIDTH = OPACITY + 4,
/**
- * @brief The color for the borderline of the visual
+ * @brief The color for the borderline of the visual.
* @details Name "borderlineColor", type Property::VECTOR4, animatable
- * @note Default value is Color::BLACK
+ * @note Default value is Color::BLACK.
+ * @note This color is affected by opacity.
*/
BORDERLINE_COLOR = OPACITY + 5,
{
uint32_t position = static_cast<uint32_t>(value.Get<int>());
DALI_LOG_INFO(gLogFilter, Debug::General, "TextEditor %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
- if(impl.mController->SetPrimaryCursorPosition(position))
+ if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
{
impl.SetKeyInputFocus();
}
}
}
+void TextEditor::SelectText(const uint32_t start, const uint32_t end)
+{
+ if(mController && mController->IsShowingRealText())
+ {
+ mController->SelectText(start, end);
+ SetKeyInputFocus();
+ }
+}
+
void TextEditor::ScrollBy(Vector2 scroll)
{
if(mController && mController->IsShowingRealText())
void SelectNone() override;
/**
+ * @copydoc Text::SelectableControlInterface::SelectText()
+ */
+ void SelectText(const uint32_t start, const uint32_t end) override;
+
+ /**
* @copydoc Dali::Toolkit::DevelTextEditor::ScrollBy()
*/
void ScrollBy(Vector2 Scroll);
{
uint32_t position = static_cast<uint32_t>(value.Get<int>());
DALI_LOG_INFO(gLogFilter, Debug::General, "TextField %p PRIMARY_CURSOR_POSITION %d\n", impl.mController.Get(), position);
- if(impl.mController->SetPrimaryCursorPosition(position))
+ if(impl.mController->SetPrimaryCursorPosition(position, impl.HasKeyInputFocus()))
{
impl.SetKeyInputFocus();
}
}
}
+void TextField::SelectText(const uint32_t start, const uint32_t end)
+{
+ if(mController && mController->IsShowingRealText())
+ {
+ mController->SelectText(start, end);
+ SetKeyInputFocus();
+ }
+}
+
string TextField::GetSelectedText() const
{
string selectedText = "";
void SelectNone() override;
/**
+ * @copydoc Text::SelectableControlInterface::SelectText()
+ */
+ void SelectText(const uint32_t start, const uint32_t end) override;
+
+ /**
* @copydoc Text::SelectableControlInterface::GetSelectedText()
*/
string GetSelectedText() const override;
{
if(EventData::INTERRUPTED != controller.mImpl->mEventData->mState)
{
+ // Init selection position
+ if(controller.mImpl->mEventData->mState == EventData::SELECTING)
+ {
+ controller.mImpl->mEventData->mLeftSelectionPosition = controller.mImpl->mEventData->mPrimaryCursorPosition;
+ controller.mImpl->mEventData->mRightSelectionPosition = controller.mImpl->mEventData->mPrimaryCursorPosition;
+ }
+
controller.mImpl->ChangeState(EventData::INACTIVE);
if(!controller.mImpl->IsShowingRealText())
}
}
+void Controller::EventHandler::SelectEvent(Controller& controller, const uint32_t start, const uint32_t end, SelectionType selectType)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "Controller::SelectEvent\n");
+
+ if(NULL != controller.mImpl->mEventData)
+ {
+ if(selectType == SelectionType::RANGE)
+ {
+ Event event(Event::SELECT_RANGE);
+ event.p2.mUint = start;
+ event.p3.mUint = end;
+ controller.mImpl->mEventData->mEventQueue.push_back(event);
+ }
+
+ controller.mImpl->mEventData->mCheckScrollAmount = true;
+ controller.mImpl->mEventData->mIsLeftHandleSelected = true;
+ controller.mImpl->mEventData->mIsRightHandleSelected = true;
+ controller.mImpl->RequestRelayout();
+ }
+}
+
void Controller::EventHandler::ProcessModifyEvents(Controller& controller)
{
Vector<ModifyEvent>& events = controller.mImpl->mModifyEvents;
static void PanEvent(Controller& controller, GestureState state, const Vector2& displacement);
static void LongPressEvent(Controller& controller, GestureState state, float x, float y);
static void SelectEvent(Controller& controller, float x, float y, SelectionType selectType);
+ static void SelectEvent(Controller& controller, const uint32_t start, const uint32_t end, SelectionType selectType);
static void ProcessModifyEvents(Controller& controller);
static void TextReplacedEvent(Controller& controller);
static void TextInsertedEvent(Controller& controller);
OnSelectNoneEvent(impl);
break;
}
+ case Event::SELECT_RANGE:
+ {
+ OnSelectRangeEvent(impl, *iter);
+ break;
+ }
}
}
}
if(impl.mEventData)
{
EventData& eventData = *impl.mEventData;
- if(eventData.mSelectionEnabled)
+ if(eventData.mSelectionEnabled && eventData.mState != EventData::INACTIVE)
{
ModelPtr& model = impl.mModel;
const Vector2& scrollPosition = model->mScrollPosition;
}
}
+void ControllerImplEventHandler::OnSelectRangeEvent(Controller::Impl& impl, const Event& event)
+{
+ if(impl.mEventData && impl.mEventData->mSelectionEnabled && impl.mEventData->mState != EventData::INACTIVE)
+ {
+ ModelPtr& model = impl.mModel;
+ const Vector2& scrollPosition = model->mScrollPosition;
+
+ // Calculate the selection index.
+ const uint32_t length = static_cast<uint32_t>(model->mLogicalModel->mText.Count());
+ const uint32_t start = std::min(event.p2.mUint, length);
+ const uint32_t end = std::min(event.p3.mUint, length);
+
+ if(start != end)
+ {
+ // Calculates the logical position from the x,y coords.
+ impl.RepositionSelectionHandles(0.f - scrollPosition.x, 0.f - scrollPosition.y, Controller::NoTextTap::HIGHLIGHT);
+
+ impl.mEventData->mLeftSelectionPosition = start;
+ impl.mEventData->mRightSelectionPosition = end;
+ }
+ }
+}
+
void ControllerImplEventHandler::OnHandlePressed(Controller::Impl& impl, const Event& event, const bool isSmoothHandlePanEnabled)
{
ModelPtr& model = impl.mModel;
*/
static void OnSelectNoneEvent(Controller::Impl& controllerImpl);
+ /**
+ * @brief Called by Controller::Impl when a select range event is received.
+ *
+ * @param controllerImpl A reference to Controller::Impl
+ * @param event The event
+ */
+ static void OnSelectRangeEvent(Controller::Impl& controllerImpl, const Event& event);
+
private:
/**
* @brief Called by OnHandleEvent when we are in the Pressed state.
EventData::EventData(DecoratorPtr decorator, InputMethodContext& inputMethodContext)
: mDecorator(decorator),
mInputMethodContext(inputMethodContext),
- mPlaceholderFont(NULL),
+ mPlaceholderFont(nullptr),
mPlaceholderTextActive(),
mPlaceholderTextInactive(),
mPlaceholderTextColor(0.8f, 0.8f, 0.8f, 0.8f), // This color has been published in the Public API (placeholder-properties.h).
return mEventData->mPrimaryCursorPosition;
}
-bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index)
+bool Controller::Impl::SetPrimaryCursorPosition(CharacterIndex index, bool focused)
{
if(nullptr == mEventData)
{
uint32_t length = static_cast<uint32_t>(mModel->mLogicalModel->mText.Count());
mEventData->mPrimaryCursorPosition = std::min(index, length);
- ChangeState(EventData::EDITING);
- mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
- mEventData->mUpdateCursorPosition = true;
- ScrollTextToMatchCursor();
+ // If there is no focus, only the value is updated.
+ if(focused)
+ {
+ ChangeState(EventData::EDITING);
+ mEventData->mLeftSelectionPosition = mEventData->mRightSelectionPosition = mEventData->mPrimaryCursorPosition;
+ mEventData->mUpdateCursorPosition = true;
+ ScrollTextToMatchCursor();
+ }
return true;
}
SELECT,
SELECT_ALL,
SELECT_NONE,
+ SELECT_RANGE,
};
union Param
return (stateToCheck == EDITING || stateToCheck == EDITING_WITH_POPUP || stateToCheck == EDITING_WITH_GRAB_HANDLE || stateToCheck == EDITING_WITH_PASTE_POPUP);
}
- DecoratorPtr mDecorator; ///< Pointer to the decorator.
- InputMethodContext mInputMethodContext; ///< The Input Method Framework Manager.
- FontDefaults* mPlaceholderFont; ///< The placeholder default font.
- std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus.
- std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
- Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color.
+ DecoratorPtr mDecorator; ///< Pointer to the decorator.
+ InputMethodContext mInputMethodContext; ///< The Input Method Framework Manager.
+ std::unique_ptr<FontDefaults> mPlaceholderFont; ///< The placeholder default font.
+ std::string mPlaceholderTextActive; ///< The text to display when the TextField is empty with key-input focus.
+ std::string mPlaceholderTextInactive; ///< The text to display when the TextField is empty and inactive.
+ Vector4 mPlaceholderTextColor; ///< The in/active placeholder text color.
/**
* This is used to delay handling events until after the model has been updated.
/**
* @copydoc Text::Controller::SetPrimaryCursorPosition()
*/
- bool SetPrimaryCursorPosition(CharacterIndex index);
+ bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
/**
* @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
{
if(NULL != controller.mImpl->mEventData)
{
- if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
- {
- controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
- }
+ // if mPlaceholderFont is null, create an instance.
+ CreatePlaceholderFont(controller);
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.family = placeholderTextFontFamily;
DALI_LOG_INFO(gLogFilter, Debug::General, "Controller::SetPlaceholderFontFamily %s\n", placeholderTextFontFamily.c_str());
{
if(NULL != controller.mImpl->mEventData)
{
- if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
- {
- controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
- }
+ // if mPlaceholderFont is null, create an instance.
+ CreatePlaceholderFont(controller);
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.weight = weight;
controller.mImpl->mEventData->mPlaceholderFont->weightDefined = true;
{
if(NULL != controller.mImpl->mEventData)
{
- if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
- {
- controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
- }
+ // if mPlaceholderFont is null, create an instance.
+ CreatePlaceholderFont(controller);
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.width = width;
controller.mImpl->mEventData->mPlaceholderFont->widthDefined = true;
{
if(NULL != controller.mImpl->mEventData)
{
- if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
- {
- controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
- }
+ // if mPlaceholderFont is null, create an instance.
+ CreatePlaceholderFont(controller);
controller.mImpl->mEventData->mPlaceholderFont->mFontDescription.slant = slant;
controller.mImpl->mEventData->mPlaceholderFont->slantDefined = true;
{
if(NULL != controller.mImpl->mEventData)
{
- if(NULL == controller.mImpl->mEventData->mPlaceholderFont)
- {
- controller.mImpl->mEventData->mPlaceholderFont = new FontDefaults();
- }
+ // if mPlaceholderFont is null, create an instance.
+ CreatePlaceholderFont(controller);
switch(type)
{
}
}
+void Controller::PlaceholderHandler::CreatePlaceholderFont(Controller& controller)
+{
+ if(nullptr == controller.mImpl->mEventData->mPlaceholderFont)
+ {
+ controller.mImpl->mEventData->mPlaceholderFont = std::unique_ptr<FontDefaults>(new FontDefaults());
+ }
+}
+
} // namespace Text
} // namespace Toolkit
static void SetPlaceholderProperty(Controller& controller, const Property::Map& map);
static void GetPlaceholderProperty(Controller& controller, Property::Map& map);
static void ShowPlaceholderText(Controller& controller);
+ static void CreatePlaceholderFont(Controller& controller);
};
} // namespace Text
EventHandler::SelectEvent(*this, x, y, selectType);
}
+void Controller::SelectEvent(const uint32_t start, const uint32_t end, SelectionType selectType)
+{
+ EventHandler::SelectEvent(*this, start, end, selectType);
+}
+
void Controller::SetTextSelectionRange(const uint32_t* start, const uint32_t* end)
{
if(mImpl->mEventData)
return mImpl->GetPrimaryCursorPosition();
}
-bool Controller::SetPrimaryCursorPosition(CharacterIndex index)
+bool Controller::SetPrimaryCursorPosition(CharacterIndex index, bool focused)
{
if(mImpl->mEventData)
{
mImpl->mEventData->mIsLeftHandleSelected = true;
mImpl->mEventData->mIsRightHandleSelected = true;
mImpl->mEventData->mCheckScrollAmount = true;
- if(mImpl->SetPrimaryCursorPosition(index))
+ if(mImpl->SetPrimaryCursorPosition(index, focused) && focused)
{
KeyboardFocusGainEvent();
return true;
SelectEvent(0.f, 0.f, SelectionType::NONE);
}
+void Controller::SelectText(const uint32_t start, const uint32_t end)
+{
+ SelectEvent(start, end, SelectionType::RANGE);
+}
+
string Controller::GetSelectedText() const
{
string text;
*/
enum SelectionType
{
- INTERACTIVE = 0x0000,
- ALL = 0x0001,
- NONE = 0x0002
+ INTERACTIVE = 0x0000, ///< Select the word where the cursor is located.
+ ALL = 0x0001, ///< Select the whole text.
+ NONE = 0x0002, ///< Unselect the whole text.
+ RANGE = 0x0003 ///< Select the range text.
};
typedef IntrusivePtr<Controller> ControllerPtr;
* @brief Used to set the Primary cursor position.
*
* @param[in] index for the Primary cursor position.
+ * @param[in] focused true if UI control has gained focus to receive key event, false otherwise.
* @return[in] true if cursor position changed, false otherwise.
*/
- bool SetPrimaryCursorPosition(CharacterIndex index);
+ bool SetPrimaryCursorPosition(CharacterIndex index, bool focused);
/**
* @brief Creates a selection event.
void SelectEvent(float x, float y, SelectionType selection);
/**
+ * @brief Creates a selection event with a selection index.
+ *
+ * It could be called from the SelectText().
+ * The start and end parameters are passed through the event.
+ *
+ * @param[in] start The start selection position.
+ * @param[in] end The end selection position.
+ * @param[in] selection type like the range.
+ */
+ void SelectEvent(const uint32_t start, const uint32_t end, SelectionType selection);
+
+ /**
* @copydoc Text::SelectableControlInterface::SetTextSelectionRange()
*/
void SetTextSelectionRange(const uint32_t* start, const uint32_t* end);
void SelectNone();
/**
+ * @copydoc Text::SelectableControlInterface::SelectText()
+ */
+ void SelectText(const uint32_t start, const uint32_t end);
+
+ /**
* @copydoc Text::SelectableControlInterface::GetSelectedText()
*/
string GetSelectedText() const;
virtual void SelectNone() = 0;
/**
+ * @brief Called to set the selection postions in the texts.
+ * @param start start selection position.
+ * @param end end selection position.
+ */
+ virtual void SelectText(const uint32_t start, const uint32_t end) = 0;
+
+ /**
* @brief Retrive Selected text.
* @return The seletced text.
*/
{
const unsigned int TOOLKIT_MAJOR_VERSION = 2;
const unsigned int TOOLKIT_MINOR_VERSION = 0;
-const unsigned int TOOLKIT_MICRO_VERSION = 37;
+const unsigned int TOOLKIT_MICRO_VERSION = 39;
const char* const TOOLKIT_BUILD_DATE = __DATE__ " " __TIME__;
#ifdef DEBUG_ENABLED
Name: dali2-toolkit
Summary: Dali 3D engine Toolkit
-Version: 2.0.37
+Version: 2.0.39
Release: 1
Group: System/Libraries
License: Apache-2.0 and BSD-3-Clause and MIT