X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcontroller%2Ftext-controller-event-handler.cpp;h=99cc2272d0605a5b457508366f4142b5cbdfcf24;hb=HEAD;hp=12fcd6902dfd0c077fd1f11cbbf8219bb5267691;hpb=f9649c1d7583b0e1af1c91f1f1518323921e6a47;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp index 12fcd69..99cc227 100644 --- a/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp +++ b/dali-toolkit/internal/text/controller/text-controller-event-handler.cpp @@ -221,8 +221,11 @@ bool Controller::EventHandler::KeyEvent(Controller& controller, const Dali::KeyE bool consumed = false; if(keyName == KEY_C_NAME || keyName == KEY_INSERT_NAME || logicalKey == KEY_C_NAME || logicalKey == KEY_INSERT_NAME) { - // Ctrl-C or Ctrl+Insert to copy the selected text - controller.TextPopupButtonTouched(Toolkit::TextSelectionPopup::COPY); + if(!keyEvent.IsRepeat()) + { + // Ctrl-C or Ctrl+Insert to copy the selected text + controller.TextPopupButtonTouched(Toolkit::TextSelectionPopup::COPY); + } consumed = true; } else if(keyName == KEY_V_NAME || logicalKey == KEY_V_NAME) @@ -376,27 +379,54 @@ void Controller::EventHandler::AnchorEvent(Controller& controller, float x, floa 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; + Vector2 visualTransformOffset = controller.mImpl->mModel->mVisualTransformOffset; + // 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, + yPosition - visualTransformOffset.y, CharacterHitTest::TAP, matchedCharacter); - for(const auto& anchor : controller.mImpl->mModel->mLogicalModel->mAnchors) + for(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) + if(controller.mImpl->mAnchorControlInterface) { - std::string href(anchor.href); + if(!anchor.isClicked) + { + anchor.isClicked = true; + // TODO: in mutable text, the anchor color and underline run index should be able to be updated. + if(!controller.IsEditable()) + { + // If there is a markup clicked color attribute, use it. Otherwise, use the property color. + if(controller.mImpl->mModel->mLogicalModel->mColorRuns.Count() > anchor.colorRunIndex) + { + ColorRun& colorRun = *(controller.mImpl->mModel->mLogicalModel->mColorRuns.Begin() + anchor.colorRunIndex); + colorRun.color = anchor.isMarkupClickedColorSet ? anchor.markupClickedColor : controller.mImpl->mAnchorClickedColor; + } + if(controller.mImpl->mModel->mLogicalModel->mUnderlinedCharacterRuns.Count() > anchor.underlinedCharacterRunIndex) + { + UnderlinedCharacterRun& underlineRun = *(controller.mImpl->mModel->mLogicalModel->mUnderlinedCharacterRuns.Begin() + anchor.underlinedCharacterRunIndex); + underlineRun.properties.color = anchor.isMarkupClickedColorSet ? anchor.markupClickedColor : controller.mImpl->mAnchorClickedColor; + } + + controller.mImpl->ClearFontData(); + controller.mImpl->mOperationsPending = static_cast(controller.mImpl->mOperationsPending | COLOR); + controller.mImpl->RequestRelayout(); + } + } + + std::string href = anchor.href == nullptr ? "" : anchor.href; controller.mImpl->mAnchorControlInterface->AnchorClicked(href); break; } @@ -738,13 +768,13 @@ bool Controller::EventHandler::DeleteEvent(Controller& controller, int keyCode) else if((controller.mImpl->mEventData->mPrimaryCursorPosition > 0) && (keyCode == Dali::DALI_KEY_BACKSPACE)) { // Remove the character before the current cursor position - removed = TextUpdater::RemoveText(controller, -1, 1, UPDATE_INPUT_STYLE); + removed = TextUpdater::RemoveText(controller, -1, 1, UPDATE_INPUT_STYLE, false); } else if((controller.mImpl->mEventData->mPrimaryCursorPosition < controller.mImpl->mModel->mLogicalModel->mText.Count()) && (keyCode == Dali::DevelKey::DALI_KEY_DELETE)) { // Remove the character after the current cursor position - removed = TextUpdater::RemoveText(controller, 0, 1, UPDATE_INPUT_STYLE); + removed = TextUpdater::RemoveText(controller, 0, 1, UPDATE_INPUT_STYLE, false); } if(removed) @@ -795,7 +825,8 @@ InputMethodContext::CallbackData Controller::EventHandler::OnInputMethodContextE const bool textDeleted = TextUpdater::RemoveText(controller, inputMethodContextEvent.cursorOffset, inputMethodContextEvent.numberOfChars, - DONT_UPDATE_INPUT_STYLE); + DONT_UPDATE_INPUT_STYLE, + false); if(textDeleted) {