void CATextField::ccStartSelect() { if (m_nInputType == KEY_BOARD_INPUT_PASSWORD) return; if (m_sText.empty()) return; int index = getStringCharCount(m_sText.substr(0, m_iCurPos)); if (index == 0) { m_curSelCharRange.first = m_iCurPos; m_curSelCharRange.second = m_iCurPos + m_vTextFiledChars.front().charSize; } else { m_curSelCharRange.first = m_iCurPos - m_vTextFiledChars[index - 1].charSize; m_curSelCharRange.second = m_iCurPos; } CATextSelectView* pSelCharsView = CATextSelectView::create(); bool l, r; CCRect cc = getZZCRect(&l, &r); pSelCharsView->showTextSelView(convertRectToWorldSpace(cc), this, l, r); m_pCursorMark->setVisible(false); // CATextArrowView::hideTextArrowView(); }
void CATextView::ccStartSelect() { if (m_szText.empty()) return; int iLastPos = m_iCurPos; if (m_iCurPos == 0) { int nMoveLen = 1; for (std::string::size_type n = m_iCurPos + nMoveLen; n < m_szText.length() && 0x80 == (0xC0 & m_szText.at(n));) { ++nMoveLen; n = m_iCurPos + nMoveLen; } m_iCurPos += nMoveLen; m_curSelCharRange.first = iLastPos; m_curSelCharRange.second = m_iCurPos; } else { int nMoveLen = 1; while (0x80 == (0xC0 & m_szText.at(m_iCurPos - nMoveLen))) { ++nMoveLen; } m_iCurPos -= nMoveLen; m_curSelCharRange.first = m_iCurPos; m_curSelCharRange.second = iLastPos; } m_pTextArrView->hideTextArrView(); m_pTextSelView->showTextSelView(this, getZZCRect(), m_iLineHeight); hideCursorMark(); }
void CATextField::moveSelectChars(bool isLeftBtn, const CCPoint& pt) { int l, r, p; calculateSelChars(convertToNodeSpace(pt), l, r, p); if (isLeftBtn) { if (p < m_curSelCharRange.second) m_curSelCharRange.first = p; } else { if (p > m_curSelCharRange.first) m_curSelCharRange.second = p; } m_iString_l_length = l; m_iString_r_length = r; bool isBackward = p < m_iCurPos; m_iCurPos = p; adjustCursorMove(!isBackward); CATextSelectView* pSelCharsView = CATextSelectView::create(); bool ll, rr; CCRect cc = convertRectToWorldSpace(getZZCRect(&ll, &rr)); pSelCharsView->showTextSelView(cc, this, ll, rr); this->hideCursorMark(); }
void CATextView::willInsertText(const char* text, int len) { execCurSelCharRange(); int iOldCurPos = m_iCurPos; insertText(text, len); m_curSelCharRange = std::make_pair(iOldCurPos, m_iCurPos); m_pTextSelView->showTextViewMark(getZZCRect()); }
void CATextView::selectAll() { m_curSelCharRange.first = 0; m_curSelCharRange.second = m_iCurPos = (int)m_szText.length(); m_pTextArrView->hideTextArrView(); m_pTextSelView->showTextSelView(this, getZZCRect(), m_iLineHeight); this->hideCursorMark(); }
void MoveMouseArrow(const DPoint& pt) { calculateSelChars(pt, m_iString_l_length, m_iString_r_length, m_iCurPos); m_curSelCharRange.first = MIN(m_iCurPos, m_iStartMovePos); m_curSelCharRange.second = MAX(m_iCurPos, m_iStartMovePos); adjustCursorMove(); m_pTextViewMark->setFrame(getZZCRect()); m_pTextViewMark->setVisible(true); }
void CATextField::willInsertText(const char *text, int len) { execCurSelCharRange(); int iOldCurPos = m_iCurPos; insertText(text, len); m_curSelCharRange = std::make_pair(iOldCurPos, m_iCurPos); m_pTextViewMark->setFrame(getZZCRect()); m_pTextViewMark->setVisible(true); }
void CATextField::selectAll() { if (m_nInputType == KEY_BOARD_INPUT_PASSWORD) return; m_curSelCharRange.first = 0; m_curSelCharRange.second = m_iCurPos = (int)m_sText.length(); CATextSelectView* pSelCharsView = CATextSelectView::create(); bool l, r; CCRect cc = getZZCRect(&l, &r); pSelCharsView->showTextSelView(convertRectToWorldSpace(cc), this, l, r); this->hideCursorMark(); }
void CATextField::willInsertText(const char *text, int len) { if (m_nInputType == KEY_BOARD_INPUT_PASSWORD) return; execCurSelCharRange(); int iOldCurPos = m_iCurPos; insertText(text, len); m_curSelCharRange = std::make_pair(iOldCurPos, m_iCurPos); m_pTextViewMark->setFrame(getZZCRect()); m_pTextViewMark->setVisible(true); }
void ShowTextViewMask() { HideTextViewMask(); int iFlagTrick = -1; std::vector<DRect> vt = getZZCRect(); for (int i = 0; i < vt.size(); i++) { CAView* pTextMaskView = CAView::createWithColor(ccc4(60, 120, 240, 127)); if (vt[i].origin.y == iFlagTrick) { vt[i].InflateRect(0, -1, 0, -1); } iFlagTrick = vt[i].origin.y + vt[i].size.height; pTextMaskView->setFrame(vt[i]); m_pContainerView->addSubview(pTextMaskView); m_vTextViewMask.push_back(pTextMaskView); } }
void CATextView::moveSelectChars(bool isLeftBtn, const CCPoint& pt) { int l, r, p; calculateSelChars(convertToNodeSpace(pt), l, r, p); if (isLeftBtn) { if (p < m_curSelCharRange.second) m_curSelCharRange.first = p; } else { if (p > m_curSelCharRange.first) m_curSelCharRange.second = p; } m_iCurPos = p; calcCursorPosition(); m_pTextArrView->hideTextArrView(); m_pTextSelView->showTextSelView(this, getZZCRect(), m_iLineHeight); hideCursorMark(); }