Exemple #1
0
void Searcher_DatonSet::pPullSuggested(const ZRef<Callable_PullFrom>& iCallable_PullFrom)
	{
	ZGuardMtxR guard(fMtxR);
	sInsert(fCallables_PullFrom, iCallable_PullFrom);
	guard.Release();
	Searcher::pTriggerSearcherResultsAvailable();
	}
void CCTextInput::insertText(const char * text, int len)
{
    std::string sInsert(text, len);

    // insert \n means input end
    int nPos = sInsert.find('\n');
    if ((int)sInsert.npos != nPos)
    {
        len = nPos;
        sInsert.erase(nPos);
    }
    
    if (len > 0)
    {
		unsigned int inputCharCount = _calcCharCount(sInsert.c_str()) + m_nCharCount;
		if(inputCharCount>m_limitNum){
			return;
		}
        m_nCharCount = inputCharCount;
        std::string sText(*m_pInputText);
        sText.append(sInsert);
        setString(sText.c_str());
    }

    if ((int)sInsert.npos == nPos) {
        return;
    }
    
    // if delegate hasn't processed, detach from IME by default
    closeIME();
}
void CCTextFieldTTF::insertText(const char * text, int len)
{
    std::string sInsert(text, len);

    // insert \n means input end
    int nPos = sInsert.find('\n');
    if ((int)sInsert.npos != nPos)
    {
        len = nPos;
        sInsert.erase(nPos);
    }
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len))
    {
        // delegate doesn't want insert text
        return;
    }
    
    m_nCharCount += _calcCharCount(sInsert.c_str());
    std::string sText(*m_pInputText);
    sText.swap(sInsert);
    setString(sText.c_str());
#else
    if (len > 0)
    {
        if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len))
        {
            // delegate doesn't want insert text
            return;
        }
        
        m_nCharCount += _calcCharCount(sInsert.c_str());
        std::string sText(*m_pInputText);
        sText.append(sInsert);
        setString(sText.c_str());
    }
#endif
    if ((int)sInsert.npos == nPos) {
        return;
    }
    
    // '\n' has inserted,  let delegate process first
    if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, "\n", 1))
    {
        return;
    }
    
    // if delegate hasn't process, detach with ime as default
    detachWithIME();
}
void CCTextFieldTTF::insertText(const char * text, int len)
{
    std::string sInsert(text, len);

    // insert \n means input end
    int nPos = sInsert.find('\n');
    //找到了 换行符号 输入就是 -1  len = -1
    //支持换行符
    if (!isMultiLine) {
        if ((int)sInsert.npos != nPos)
        {
            len = nPos;
            sInsert.erase(nPos);
        }
    }
    
    //换行符就不输入文字了
    if (len > 0)
    {
        //代理处理插入了字符 只在有最长限制的时候
        if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len))
        {
            // delegate doesn't want to insert text
            return;
        }

        m_nCharCount += _calcCharCount(sInsert.c_str());
        std::string sText(*m_pInputText);
        sText.append(sInsert);
        setString(sText.c_str());
    }

    //不是换行符 处理完毕 或者支持多行文本
    if (isMultiLine || (int)sInsert.npos == nPos) {
        return;
    }

    //代理处理换行符
    // '\n' inserted, let delegate process first
    if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, "\n", 1))
    {
        return;
    }

    //当点击背后的屏幕的时候 没有在键盘范围则退出场景即可
    // if delegate hasn't processed, detach from IME by default
    detachWithIME();
}
void CCTextFieldTTF::insertText(const char * text, int len)
{
    std::string sInsert(text, len);

    // insert \n means input end
    int nPos = sInsert.find('\n');
    if ((int)sInsert.npos != nPos)
    {
        len = nPos;
        sInsert.erase(nPos);
    }

    if (len > 0)
    {
        if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len))
        {
            // delegate doesn't want to insert text
            return;
        }

        m_nCharCount += _calcCharCount(sInsert.c_str());
        std::string sText(*m_pInputText);
        sText.append(sInsert);
        setString(sText.c_str());
        //////
        
    
        ///////
   
     
    }

    if ((int)sInsert.npos == nPos) {
        return;
    }

    // '\n' inserted, let delegate process first
    if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, "\n", 1))
    {
        return;
    }

    // if delegate hasn't processed, detach from IME by default
    detachWithIME();
}
Exemple #6
0
void CCtrlTextFieldTTF::insertText(const char * text, int len)
{
	std::string sInsert(text, len);

	// insert \n means input end
	int nPos = sInsert.find('\n');
	if ((int)sInsert.npos != nPos)
	{
		len = nPos;
		sInsert.erase(nPos);
	}

	if (len > 0)
	{
		if (EditInputFlagAll == m_nInputType)
		{
			if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len))
			{
				// delegate doesn't want to insert text
				return;
			}

			m_strText.append(sInsert);
			m_nCharCount += _calcCharCount(sInsert.c_str());
			std::string sText(*m_pInputText);
			sText.append(sInsert);
			setString(sText.c_str());
		}
		else if (EditInputFlagPassword == m_nInputType)
		{
			int nInsertSize = _calcCharCount(sInsert.c_str());
			std::string strInsert = "";
			for (int i=0; i<nInsertSize; ++i)
			{
				strInsert.append("*");
			}

			if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, strInsert.c_str(), nInsertSize))
			{
				// delegate doesn't want to insert text
				return;
			}

			m_strText.append(sInsert);
			m_nCharCount += nInsertSize;
			std::string sText(*m_pInputText);
			sText.append(strInsert);			

			setString(sText.c_str());
		}

		if (EventChanged)
		{
			EventChanged();
		}
	}

	if ((int)sInsert.npos == nPos) {
		return;
	}

	// '\n' inserted, let delegate process first
	if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, "\n", 1))
	{
		return;
	}

	// if delegate hasn't processed, detach from IME by default
	detachWithIME();
}
Exemple #7
0
void CATextField::insertText(const char * text, int len)
{
    if (spaceHolderIsOn)
    {
        m_pText->setText("");
        m_pText->setTextcolor(m_cTextColor);
        spaceHolderIsOn=false;
        
    }
    std::string sInsert(text, len);
    
    // insert \n means input end
    int nPos = sInsert.find('\n');
    if ((int)sInsert.npos != nPos)
    {
        len = nPos;
        sInsert.erase(nPos);
    }
    
    if (len > 0)
    {
        if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, sInsert.c_str(), len))
        {
            
            
            // delegate doesn't want to insert text
            return;
        }
        m_nCharCount += _calcCharCount(sInsert.c_str());
        std::string sText(m_pText->getText());
        std::string oldstr = sText;
        sText.append(sInsert);
        
        float length = 0;
        
        m_pText->setText(sText.c_str());
        
        CCRect rect = CCRectZero;
        rect.size = this->getBounds().size;
        rect.size.width = MIN(this->getBounds().size.width, m_pText->getLabelSize().width);
        
        if (m_pText->getLabelSize().width < this->getBounds().size.width)
        {
            m_pText->setFrame(rect);
            m_pMark->setCenterOrigin(CCPoint(m_pText->getLabelSize().width, this->getBounds().size.height/2));
        }
        else
        {
            m_pText->setText(oldstr);
            m_pText->setFrame(rect);
            m_pMark->setCenterOrigin(CCPoint(m_pText->getLabelSize().width, this->getBounds().size.height/2));
        }
        
        if (_oldPos != 0)
        {
            length = m_pText->getLabelSize().width - _oldPos;
        }
        else
        {
            length = m_pText->getLabelSize().width;
        }
        
    }
    
    if ((int)sInsert.npos == nPos) {
        return;
    }
    
    if (m_pDelegate && m_pDelegate->onTextFieldInsertText(this, "\n", 1))
    {
        return;
    }
    
    // if delegate hasn't processed, detach from IME by default
    detachWithIME();
}