예제 #1
0
bool CATextField::becomeFirstResponder()
{
	bool result = CAView::becomeFirstResponder();
    if (result) 
	{
		attachWithIME();
        this->showCursorMark();
        if (m_nInputType == KEY_BOARD_INPUT_PASSWORD)
        {
            if (m_sText.empty())
            {
                m_pCursorMark->setCenterOrigin(CCPoint(getCursorX() + m_iHoriMargins, m_obContentSize.height / 2));
            }
        }
        calculateSelChars(CCPoint(this->getCursorX() + m_iHoriMargins, m_obContentSize.height / 2), 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
    }
    return result;
}
예제 #2
0
void CATextView::pasteFromClipboard()
{
	std::string cszText = CAClipboard::getText();
	insertText(cszText.c_str(), (int)cszText.size());

#if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID
	CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
	pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
}
예제 #3
0
void CATextView::setText(const std::string& var)
{
	CATextViewDelegate* pTemp = m_pTextViewDelegate;
	m_pTextViewDelegate = NULL;
	m_szText.clear();
	m_iCurPos = 0;
	m_vLinesTextView.clear();
	m_curSelCharRange = std::make_pair(0, 0);
	insertText(var.c_str(), (int)var.length());
	m_pTextViewDelegate = pTemp;
	m_bUpdateImage = true;
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
	CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
	pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
}
예제 #4
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();
}
예제 #5
0
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);
}
예제 #6
0
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();
}
예제 #7
0
bool CATextField::becomeFirstResponder()
{
	resignAllResponder(this);
    
	bool result = CAView::becomeFirstResponder();
    if (result) 
	{
		result = attachWithIME();
        this->showCursorMark();

        calculateSelChars(CCPoint(this->getCursorX() + m_iHoriMargins, m_obContentSize.height / 2), m_iString_l_length, m_iString_r_length, m_iCurPos);
        setCursorPosition();

#if CC_TARGET_PLATFORM==CC_PLATFORM_ANDROID
        CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
        pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
    }
    return result;
}
예제 #8
0
void CATextField::setText(const std::string &var)
{
    CATextFieldDelegate* pTemp = m_pDelegate;
    m_pDelegate = NULL;
    m_sText.clear();
	m_iCurPos = 0;
	m_curSelCharRange = std::make_pair(0, 0);
	m_iString_o_length = 0;
	m_iString_l_length = 0;
	m_iString_r_length = 0;
	m_vTextFiledChars.clear();
    CCPoint p = CCPoint(this->getCursorX() + m_iHoriMargins, m_obContentSize.height / 2);
    m_pCursorMark->setCenterOrigin(p);
    insertText(var.c_str(), (int)var.length());
    m_pDelegate = pTemp;
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
	CCEGLView * pGlView = CAApplication::getApplication()->getOpenGLView();
	pGlView->setIMECursorPos(getCursorPos(), getContentText());
#endif
}