Пример #1
0
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();
}
Пример #2
0
bool CATextField::resignFirstResponder()
{
	bool result = CAView::resignFirstResponder();
    if (result)
    {
		result = detachWithIME();
        hideCursorMark();
    }
    return result;
}
Пример #3
0
bool CATextView::resignFirstResponder()
{
	bool result = CAView::resignFirstResponder();
	if (result)
	{
		detachWithIME();
		hideCursorMark();
        m_pTextSelView->hideTextSelView();
	}
	return result;
}
Пример #4
0
void CATextView::initMarkSprite()
{
	if (m_pCursorMark == NULL)
	{
		m_pCursorMark = CAView::create();
		m_pCursorMark->setColor(m_cCursorColor);
		m_pContainerView->addSubview(m_pCursorMark);
        hideCursorMark();
	}
	m_pCursorMark->setFrame(CCRect(0, 0, 2, m_iLineHeight));
}
Пример #5
0
bool CATextField::resignFirstResponder()
{
	bool result = CAView::resignFirstResponder();
    if (result)
    {
		detachWithIME();
        hideCursorMark();
        //this->updateImage();
    }
    return result;
}
Пример #6
0
void CATextField::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent)
{
    CCPoint point = this->convertTouchToNodeSpace(pTouch);
    
    if (this->getBounds().containsPoint(point))
    {
		becomeFirstResponder();
		if (isFirstResponder())
        {
            this->showCursorMark();
            if (m_nInputType == KEY_BOARD_INPUT_PASSWORD)
            {
                if (!m_sText.empty())
                {
                    m_iCurPos =(int)m_vTextFiledChars.size();
                    m_iString_l_length = m_cImageSize.width;
                }
                m_pCursorMark->setCenterOrigin(CCPoint(getCursorX() + m_iHoriMargins, m_obContentSize.height / 2));

                return;
            }
			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
    {
        hideCursorMark();
        
        if (resignFirstResponder())
        {
			this->updateImage();
        }
    }

	m_curSelCharRange = std::make_pair(m_iCurPos, m_iCurPos);
	execCurSelCharRange();
}
Пример #7
0
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();
}
Пример #8
0
void CATextView::didDetachWithIME()
{
    hideCursorMark();
}
Пример #9
0
void CATextView::didDetachWithIME()
{
    hideCursorMark();
	m_bKeyboardOpen = false;
}
Пример #10
0
void CATextField::didDetachWithIME()
{
    hideCursorMark();
}
Пример #11
0
void CATextField::resignResponder()
{
	detachWithIME();
	hideCursorMark();
}