DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED)
DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
+DALI_SIGNAL_REGISTRATION(Toolkit, TextEditor, "anchorClicked", SIGNAL_ANCHOR_CLICKED )
DALI_TYPE_REGISTRATION_END()
// clang-format on
return mMaxLengthReachedSignal;
}
+DevelTextEditor::AnchorClickedSignalType& TextEditor::AnchorClickedSignal()
+{
+ return mAnchorClickedSignal;
+}
+
Text::ControllerPtr TextEditor::getController()
{
return mController;
editorImpl.MaxLengthReachedSignal().Connect(tracker, functor);
}
}
+ else if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
+ {
+ if(editor)
+ {
+ Internal::TextEditor& editorImpl(GetImpl(editor));
+ editorImpl.AnchorClickedSignal().Connect(tracker, functor);
+ }
+ }
else
{
// signalName does not match any signal
{
Actor self = Self();
- mController = Text::Controller::New(this, this, this);
+ mController = Text::Controller::New(this, this, this, this);
mDecorator = Text::Decorator::New(*mController,
*mController);
padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
const Vector2& localPoint = gesture.GetLocalPoint();
mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top);
+ mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
SetKeyInputFocus();
}
mInputStyleChangedSignal.Emit(handle, editorInputStyleMask);
}
+void TextEditor::AnchorClicked(const std::string& href)
+{
+ Dali::Toolkit::TextEditor handle(GetOwner());
+ mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
+}
+
void TextEditor::AddDecoration(Actor& actor, bool needsClipping)
{
if(actor)
std::string TextEditor::AccessibleImpl::GetName()
{
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
return slf.GetProperty(Toolkit::TextEditor::Property::TEXT)
.Get<std::string>();
}
if(endOffset <= startOffset)
return {};
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto txt =
slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
size_t TextEditor::AccessibleImpl::GetCharacterCount()
{
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto txt =
slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
size_t TextEditor::AccessibleImpl::GetCaretOffset()
{
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
return Dali::Toolkit::GetImpl(slf).getController()->GetCursorPosition();
}
bool TextEditor::AccessibleImpl::SetCaretOffset(size_t offset)
{
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
if(offset > txt.size())
return false;
Dali::Accessibility::Range TextEditor::AccessibleImpl::GetTextAtOffset(
size_t offset, Dali::Accessibility::TextBoundary boundary)
{
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
auto txt_size = txt.size();
if(selectionNum > 0)
return {};
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto ctrl = Dali::Toolkit::GetImpl(slf).getController();
std::string ret;
ctrl->RetrieveSelection(ret);
if(selectionNum > 0)
return false;
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
Dali::Toolkit::GetImpl(slf).getController()->SetSelection(0, 0);
return true;
}
if(selectionNum > 0)
return false;
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
Dali::Toolkit::GetImpl(slf).getController()->SetSelection(startOffset,
endOffset);
return true;
if(endPosition <= startPosition)
return false;
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
if(endPosition <= startPosition)
return false;
- auto slf = Toolkit::TextEditor::DownCast(self);
+ auto slf = Toolkit::TextEditor::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextEditor::Property::TEXT).Get<std::string>();
Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "textChanged", SIGNAL_TEXT_CHANGED )
DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "maxLengthReached", SIGNAL_MAX_LENGTH_REACHED )
DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "inputStyleChanged", SIGNAL_INPUT_STYLE_CHANGED)
+DALI_SIGNAL_REGISTRATION(Toolkit, TextField, "anchorClicked", SIGNAL_ANCHOR_CLICKED )
DALI_TYPE_REGISTRATION_END()
// clang-format on
{
field.InputStyleChangedSignal().Connect(tracker, functor);
}
+ else if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
+ {
+ if(field)
+ {
+ Internal::TextField& fieldImpl(GetImpl(field));
+ fieldImpl.AnchorClickedSignal().Connect(tracker, functor);
+ }
+ }
else
{
// signalName does not match any signal
return mInputStyleChangedSignal;
}
+DevelTextField::AnchorClickedSignalType& TextField::AnchorClickedSignal()
+{
+ return mAnchorClickedSignal;
+}
+
void TextField::OnInitialize()
{
Actor self = Self();
- mController = Text::Controller::New(this, this, this);
+ mController = Text::Controller::New(this, this, this, this);
// When using the vector-based rendering, the size of the GLyphs are different
TextAbstraction::GlyphType glyphType = (DevelText::RENDERING_VECTOR_BASED == mRenderingBackend) ? TextAbstraction::VECTOR_GLYPH : TextAbstraction::BITMAP_GLYPH;
padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
const Vector2& localPoint = gesture.GetLocalPoint();
mController->TapEvent(gesture.GetNumberOfTaps(), localPoint.x - padding.start, localPoint.y - padding.top);
+ mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
SetKeyInputFocus();
}
mInputStyleChangedSignal.Emit(handle, fieldInputStyleMask);
}
+void TextField::AnchorClicked(const std::string& href)
+{
+ Dali::Toolkit::TextField handle(GetOwner());
+ mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
+}
+
void TextField::AddDecoration(Actor& actor, bool needsClipping)
{
if(actor)
std::string TextField::AccessibleImpl::GetName()
{
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
return slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
}
if(endOffset <= startOffset)
return {};
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto txt =
slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
size_t TextField::AccessibleImpl::GetCharacterCount()
{
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto txt =
slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
size_t TextField::AccessibleImpl::GetCaretOffset()
{
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
return Dali::Toolkit::GetImpl(slf).getController()->GetCursorPosition();
}
bool TextField::AccessibleImpl::SetCaretOffset(size_t offset)
{
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
if(offset > txt.size())
return false;
Dali::Accessibility::Range TextField::AccessibleImpl::GetTextAtOffset(
size_t offset, Dali::Accessibility::TextBoundary boundary)
{
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
auto txt_size = txt.size();
if(selectionNum > 0)
return {};
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto ctrl = Dali::Toolkit::GetImpl(slf).getController();
std::string ret;
ctrl->RetrieveSelection(ret);
if(selectionNum > 0)
return false;
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
Dali::Toolkit::GetImpl(slf).getController()->SetSelection(0, 0);
return true;
}
if(selectionNum > 0)
return false;
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
Dali::Toolkit::GetImpl(slf).getController()->SetSelection(startOffset,
endOffset);
return true;
if(endPosition <= startPosition)
return false;
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
if(endPosition <= startPosition)
return false;
- auto slf = Toolkit::TextField::DownCast(self);
+ auto slf = Toolkit::TextField::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextField::Property::TEXT).Get<std::string>();
Dali::Toolkit::GetImpl(slf).getController()->CopyStringToClipboard(txt.substr(startPosition, endPosition - startPosition));
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit, TextLabel, "textColorGreen", TEXT_COLOR_GREEN, TEXT_COLOR, 1)
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit, TextLabel, "textColorBlue", TEXT_COLOR_BLUE, TEXT_COLOR, 2)
DALI_ANIMATABLE_PROPERTY_COMPONENT_REGISTRATION(Toolkit, TextLabel, "textColorAlpha", TEXT_COLOR_ALPHA, TEXT_COLOR, 3)
+
+DALI_SIGNAL_REGISTRATION(Toolkit, TextLabel, "anchorClicked", SIGNAL_ANCHOR_CLICKED)
+
DALI_TYPE_REGISTRATION_END()
// clang-format on
return value;
}
+bool TextLabel::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
+{
+ Dali::BaseHandle handle(object);
+
+ bool connected(true);
+ Toolkit::TextLabel label = Toolkit::TextLabel::DownCast(handle);
+
+ if(0 == strcmp(signalName.c_str(), SIGNAL_ANCHOR_CLICKED))
+ {
+ if(label)
+ {
+ Internal::TextLabel& labelImpl(GetImpl(label));
+ labelImpl.AnchorClickedSignal().Connect(tracker, functor);
+ }
+ }
+ else
+ {
+ // signalName does not match any signal
+ connected = false;
+ }
+
+ return connected;
+}
+
+DevelTextLabel::AnchorClickedSignalType& TextLabel::AnchorClickedSignal()
+{
+ return mAnchorClickedSignal;
+}
+
void TextLabel::OnInitialize()
{
Actor self = Self();
DALI_ASSERT_DEBUG(mController && "Invalid Text Controller")
mController->SetControlInterface(this);
+ mController->SetAnchorControlInterface(this);
// Use height-for-width negotiation by default
self.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH);
Dali::LayoutDirection::Type layoutDirection = static_cast<Dali::LayoutDirection::Type>(stage.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>());
mController->SetLayoutDirection(layoutDirection);
+ // Forward input events to controller
+ EnableGestureDetection(static_cast<GestureType::Value>(GestureType::TAP));
+ GetTapGestureDetector().SetMaximumTapsRequired(1);
+
Layout::Engine& engine = mController->GetLayoutEngine();
engine.SetCursorWidth(0u); // Do not layout space for the cursor.
Control::OnStyleChange(styleManager, change);
}
+void TextLabel::OnTap(const TapGesture& gesture)
+{
+ DALI_LOG_INFO(gLogFilter, Debug::Verbose, "TextLabel::OnTap %p\n", mController.Get());
+
+ // Deliver the tap before the focus event to controller; this allows us to detect when focus is gained due to tap-gestures
+ Extents padding;
+ padding = Self().GetProperty<Extents>(Toolkit::Control::Property::PADDING);
+ const Vector2& localPoint = gesture.GetLocalPoint();
+ mController->AnchorEvent(localPoint.x - padding.start, localPoint.y - padding.top);
+}
+
+void TextLabel::AnchorClicked(const std::string& href)
+{
+ Dali::Toolkit::TextLabel handle(GetOwner());
+ mAnchorClickedSignal.Emit(handle, href.c_str(), href.length());
+}
+
Vector3 TextLabel::GetNaturalSize()
{
Extents padding;
std::string TextLabel::AccessibleImpl::GetNameRaw()
{
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
return slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
}
if(endOffset <= startOffset)
return {};
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
auto txt =
slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
size_t TextLabel::AccessibleImpl::GetCharacterCount()
{
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
auto txt =
slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
Dali::Accessibility::Range TextLabel::AccessibleImpl::GetTextAtOffset(
size_t offset, Dali::Accessibility::TextBoundary boundary)
{
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
auto txt = slf.GetProperty(Toolkit::TextLabel::Property::TEXT).Get<std::string>();
auto txt_size = txt.size();
if(selectionNum > 0)
return {};
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
auto ctrl = Dali::Toolkit::GetImpl(slf).getController();
std::string ret;
ctrl->RetrieveSelection(ret);
if(selectionNum > 0)
return false;
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
Dali::Toolkit::GetImpl(slf).getController()->SetSelection(0, 0);
return true;
}
if(selectionNum > 0)
return false;
- auto slf = Toolkit::TextLabel::DownCast(self);
+ auto slf = Toolkit::TextLabel::DownCast(Self());
Dali::Toolkit::GetImpl(slf).getController()->SetSelection(startOffset,
endOffset);
return true;