X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Ftext-controller-event-handler.cpp;h=c17c8205b31532c27eef4768dc4fd002d85c0c24;hb=93ad73e0e2c46aca4c191a1e2f075061e167e8b5;hp=ce0bf598a3d5060c84ca9fb723ea051994886e9b;hpb=538e266eef5a998be3d6d4b6e1019ecd313d59d4;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/text-controller-event-handler.cpp b/dali-toolkit/internal/text/text-controller-event-handler.cpp index ce0bf59..c17c820 100644 --- a/dali-toolkit/internal/text/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/text-controller-event-handler.cpp @@ -24,6 +24,7 @@ #include // INTERNAL INCLUDES +#include #include #include @@ -293,6 +294,46 @@ bool Controller::EventHandler::KeyEvent(Controller& controller, const Dali::KeyE return true; } +void Controller::EventHandler::AnchorEvent(Controller& controller, float x, float y) +{ + if(!controller.mImpl->mMarkupProcessorEnabled || + !controller.mImpl->mModel->mLogicalModel->mAnchors.Count() || + !controller.mImpl->IsShowingRealText()) + { + return; + } + + CharacterIndex cursorPosition = 0u; + + // Convert from control's coords to text's coords. + const float xPosition = x - controller.mImpl->mModel->mScrollPosition.x; + const float yPosition = y - controller.mImpl->mModel->mScrollPosition.y; + + // Whether to touch point hits on a glyph. + bool matchedCharacter = false; + cursorPosition = Text::GetClosestCursorIndex(controller.mImpl->mModel->mVisualModel, + controller.mImpl->mModel->mLogicalModel, + controller.mImpl->mMetrics, + xPosition, + yPosition, + CharacterHitTest::TAP, + matchedCharacter); + + for(const auto& anchor : controller.mImpl->mModel->mLogicalModel->mAnchors) + { + // Anchor clicked if the calculated cursor position is within the range of anchor. + if(cursorPosition >= anchor.startIndex && cursorPosition < anchor.endIndex) + { + if(controller.mImpl->mAnchorControlInterface && anchor.href) + { + std::string href(anchor.href); + controller.mImpl->mAnchorControlInterface->AnchorClicked(href); + break; + } + } + } +} + void Controller::EventHandler::TapEvent(Controller& controller, unsigned int tapCount, float x, float y) { DALI_ASSERT_DEBUG(controller.mImpl->mEventData && "Unexpected TapEvent");