Exemplo n.º 1
0
void CATextView::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent)
{
    DPoint point = this->convertTouchToNodeSpace(pTouch);
    
    if (this->getBounds().containsPoint(point))
    {
        becomeFirstResponder();
    }
    else
    {
        resignFirstResponder();
    }
}
Exemplo n.º 2
0
void CATextSelectView::hideTextSelView()
{
	resignFirstResponder();

	if (m_pControlView)
	{
		m_pControlView->becomeFirstResponder();
		m_pControlView = NULL;
	}

	removeFromSuperview();

	CAApplication::getApplication()->updateDraw();
}
Exemplo n.º 3
0
bool CATextField::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
	DPoint point = this->convertTouchToNodeSpace(pTouch);

	if (this->getBounds().containsPoint(point))
	{
		becomeFirstResponder();
		((CATextFieldWin32*)m_pTextField)->StartMouseMove(point);
	}
	else
	{
		resignFirstResponder();
		((CATextFieldWin32*)m_pTextField)->EndMouseMoveArr();
	}
    return true;
}
Exemplo n.º 4
0
bool CATextSelectView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
	CCPoint cTouchPoint = this->convertTouchToNodeSpace(pTouch);

	CCRect newRectL = m_pCursorMarkL->getFrame();
	newRectL.InflateRect(8);
	CCRect newRectR = m_pCursorMarkR->getFrame();
	newRectR.InflateRect(8);

	m_iSelViewTouchPos = 0;
	if (newRectL.containsPoint(cTouchPoint))
	{
		m_iSelViewTouchPos = 1;
		return true;
	}

	if (newRectR.containsPoint(cTouchPoint))
	{
		m_iSelViewTouchPos = 2;
		return true;
	}

	CCPoint point = this->convertTouchToNodeSpace(pTouch);

	CCRect ccTextRect = m_pTextViewMask->getFrame();
	if (ccTextRect.containsPoint(point))
	{
		CATextToolBarView *pToolBar = CATextToolBarView::create();
		pToolBar->addButton(UTF8("\u526a\u5207"), this, callfunc_selector(CATextSelectView::ccCutToClipboard));
		pToolBar->addButton(UTF8("\u590d\u5236"), this, callfunc_selector(CATextSelectView::ccCopyToClipboard));
		pToolBar->addButton(UTF8("\u7c98\u8d34"), this, callfunc_selector(CATextSelectView::ccPasteFromClipboard));
		pToolBar->show();
	}
	else
	{
		if (resignFirstResponder())
		{
			hideTextSelView();
		}
		else
		{
			becomeFirstResponder();
		}
	}
	return true;
}
Exemplo n.º 5
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();
}
Exemplo n.º 6
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);
}
Exemplo n.º 7
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();
}
Exemplo n.º 8
0
void CATextView::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent)
{
	CAScheduler::unschedule(schedule_selector(CATextView::ccTouchTimer), this);

	if (CATextToolBarView::isTextToolBarShow() || m_pTextSelView->isTextViewShow())
		return;
	
	CCPoint point = this->convertTouchToNodeSpace(pTouch);

	if (!isScrollWindowNotOutSide())
	{
		if (this->getBounds().containsPoint(point))
		{
			becomeFirstResponder();
			if (isFirstResponder())
			{
                this->showCursorMark();

				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 + getContentOffset().y));
			}
		}
		else
		{
			m_pTextArrView->hideTextArrView();
			m_pTextSelView->hideTextSelView();

			if (resignFirstResponder())
			{
                this->hideCursorMark();
			}
		}
	}

	m_curSelCharRange = std::make_pair(m_iCurPos, m_iCurPos);
	execCurSelCharRange();
	CAScrollView::ccTouchEnded(pTouch, pEvent);
}
Exemplo n.º 9
0
void CATextToolBarView::ccTouchEnded(CATouch *pTouch, CAEvent *pEvent)
{
    resignFirstResponder();
    removeFromSuperview();
}
Exemplo n.º 10
0
void CATextView::onExitTransitionDidStart()
{
    CAView::onExitTransitionDidStart();
    resignFirstResponder();
}
Exemplo n.º 11
0
bool CATextView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
	if (m_pTouches->count() > 0)
	{
		m_pTouches->replaceObjectAtIndex(0, pTouch);
		return true;
	}
	bool isInertia = m_tInertia.getLength() < 1.0f;
	if (!CAScrollView::ccTouchBegan(pTouch, pEvent))
		return false;

	CCPoint point = this->convertTouchToNodeSpace(pTouch);

	if (this->getBounds().containsPoint(point))
	{
		becomeFirstResponder();
		if (isFirstResponder())
		{
			m_pCursorMark->setVisible(true);

			point.y += getContentOffset().y;
			int iCurLine = point.y / m_iLineHeight;
			if (m_vLinesTextView.empty())
			{
				iCurLine = 0;
			}
			else if (iCurLine >= m_vLinesTextView.size())
			{
				iCurLine = m_vLinesTextView.size() - 1;
			}
			
			int iHalfCharSize = 0;
			int iStartPos = 0;
			if (!m_vLinesTextView.empty())
			{
				m_iCurPos = iStartPos = m_vLinesTextView[iCurLine].iStartCharPos;
				std::vector<TextAttribute>& v = m_vLinesTextView[iCurLine].TextAttrVect;
				for (int i = 0, iStringLeftX = 0; i < v.size(); i++)
				{
					TextAttribute& t = v[i];
					if (point.x >= iStringLeftX - iHalfCharSize && point.x < iStringLeftX + t.charlength / 2)
					{
						break;
					}

					iStringLeftX += t.charlength;
					m_iCurPos += t.charSize;
					iHalfCharSize = t.charlength / 2;
				}
			}

			std::string s = m_szText.substr(iStartPos, m_iCurPos - iStartPos);
			if (!s.empty() && s[0] == '\n')
			{
				s.erase(0, 1);
			}
			m_pCursorMark->setCenterOrigin(CCPoint(getStringLength(s), (iCurLine * 2 + 1) * (m_iLineHeight / 2)));
		}
		return true;
	}
	else
	{
		if (resignFirstResponder())
		{
			m_pCursorMark->setVisible(false);
			return false;
		}
		return false;
	}

	return true;
}
Exemplo n.º 12
0
bool CATextField::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
    if (isEditing)
    {
        return false;
    }
    CCPoint point = this->convertTouchToNodeSpace(pTouch);

    if (this->getBounds().containsPoint(point))
    {
        becomeFirstResponder();
        if (isFirstResponder())
        {

            m_pMark->setVisible(true);
            attachWithIME();

            if (m_nInputType ==KEY_BOARD_INPUT_PASSWORD)
            {
                m_pMark->setCenterOrigin(CCPoint(labelOrginX+m_rLabelRect.size.width, this->getBounds().size.height/2));
                return true;
            }
            m_fString_left_length = 0;
            int byteCount = 0;
            for (std::vector<TextAttribute>::iterator itr = m_vByteLengthArr.begin(); itr!=m_vByteLengthArr.end(); itr++)
            {
                TextAttribute t =*(itr);
                m_fString_left_length+=t.charlength;
                byteCount += t.charsize;
                if (m_fString_left_length>point.x-m_fString_left_offX)
                {
                    m_sLeft_string = m_sText.substr(0,byteCount);
                    m_sRight_string = m_sText.substr(byteCount,m_sText.length());
                    m_fString_right_length = m_rLabelRect.size.width-m_fString_left_length;
                    break;
                } else if(itr == m_vByteLengthArr.end()-1&&!spaceHolderIsOn)
                {
                    m_sLeft_string = m_sText.substr(0,byteCount);
                    m_sRight_string = m_sText.substr(byteCount,m_sText.length());
                    m_fString_right_length = m_rLabelRect.size.width-m_fString_left_length;
                }

            }
            m_pMark->setCenterOrigin(CCPoint(getCursorX()+labelOrginX, this->getBounds().size.height/2));


        }
        return true;
    }
    else
    {
        if (resignFirstResponder())
        {
            if (!strcmp(m_sText.c_str(), ""))
            {
                m_sText="";
                spaceHolderIsOn=true;
                this->updateImage();
            }
            m_pMark->setVisible(false);
            return false;
        }
        return false;
    }

    return true;
}