void CATextView::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent) { if (CATextToolBarView::isTextToolBarShow()) return; if (m_bMoved) { m_bMoved = false; return; } CCPoint point = this->convertTouchToNodeSpace(pTouch); if (this->getBounds().containsPoint(point)) { if (canAttachWithIME() && !m_pTextSelView->isTextViewShow()) { becomeFirstResponder(); int iCurLine = 0; int iCurPosX = 0; calculateSelChars(point, iCurLine, iCurPosX, m_iCurPos); m_pCursorMark->setCenterOrigin(CCPoint(iCurPosX, m_iLineHeight*1.25f*iCurLine + m_iLineHeight / 2)); CCPoint pt = m_pCursorMark->getCenterOrigin(); m_pTextArrView->showTextArrView(CCPoint(pt.x, pt.y + m_iLineHeight*1.2f + m_pContainerView->getContentOffset().y)); m_curSelCharRange = std::pair<int,int>(m_iCurPos, m_iCurPos); #if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView(); pGlView->setIMECursorPos(getStringCharCount(m_szText), getContentText()); #endif } } else { if (canDetachWithIME()) { resignFirstResponder(); } } CATouchView::ccTouchEnded(pTouch, pEvent); }
void CATextField::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent) { CATouchView::ccTouchEnded(pTouch, pEvent); if (CATextToolBarView::isTextToolBarShow()) return; if (m_bMoved) { m_bMoved = false; return; } CCPoint point = this->convertTouchToNodeSpace(pTouch); if (this->getBounds().containsPoint(point)) { if (canAttachWithIME()) { becomeFirstResponder(); calculateSelChars(point, m_iString_l_length, m_iString_r_length, m_iCurPos); m_pCursorMark->setCenterOrigin(CCPoint(getCursorX() + m_iHoriMargins, m_obContentSize.height / 2)); #if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView(); pGlView->setIMECursorPos(getCursorPos(), getContentText()); #endif } } else { if (canDetachWithIME()) { resignFirstResponder(); } } m_curSelCharRange = std::make_pair(m_iCurPos, m_iCurPos); execCurSelCharRange(); }