//textView delegate
	JNIEXPORT void JNICALL Java_org_CrossApp_lib_CrossAppTextView_keyBoardHeightReturn(JNIEnv *env, jclass cls, jint key, jint height)
    {
		CATextView* textView = s_map[(int)key];
        if (textView->getDelegate())
        {
            textView->getDelegate()->keyBoardHeight(textView, (int)s_px_to_dip(height));
        }
    }
	JNIEXPORT void JNICALL Java_org_CrossApp_lib_CrossAppTextView_resignFirstResponder(JNIEnv *env, jclass cls, jint key)
    {
		CATextView* textView = s_map[(int)key];
        if (textView->isFirstResponder())
        {
            textView->resignFirstResponder();
        }
    }
Beispiel #3
0
CATextView* CATextView::createWithCenter(const CCRect& rect)
{
	CATextView *text = new CATextView();
	if (text && text->initWithCenter(rect))
	{
		text->autorelease();
		return text;
	}
	CC_SAFE_DELETE(text);
	return NULL;
}
Beispiel #4
0
CATextView* CATextView::createWithFrame(const CCRect& frame)
{
	CATextView *text = new CATextView();
	if (text && text->initWithFrame(frame))
	{
		text->autorelease();
		return text;
	}
	CC_SAFE_DELETE(text);
	return NULL;
}
 //return call back
 JNIEXPORT void JNICALL Java_org_CrossApp_lib_CrossAppTextView_keyBoardReturnCallBack(JNIEnv *env, jclass cls, jint key, jint height)
 {
     CATextView* textView = s_map[(int)key];
     
     textView->resignFirstResponder();
     
     if (textView->getDelegate())
     {
         textView->getDelegate()->textViewShouldReturn(textView);
     }
 }
Beispiel #6
0
CATextView* CATextView::createWithCenter(const CCRect& rect)
{
	CATextView* pTextView = new CATextView();
	if (pTextView && pTextView->initWithCenter(rect))
	{
		pTextView->autorelease();
		return pTextView;
	}
	CC_SAFE_DELETE(pTextView);
	return NULL;
}
Beispiel #7
0
CATextView* CATextView::createWithLayout(const DLayout& layout)
{
    CATextView* textView = new CATextView();
    if (textView&&textView->initWithLayout(layout))
    {
        textView->autorelease();
        return textView;
    }
    
    CC_SAFE_RELEASE_NULL(textView);
    return NULL;
}
	JNIEXPORT void JNICALL Java_org_CrossApp_lib_CrossAppTextView_text(JNIEnv *env, jclass cls, jint key, jbyteArray textBuffer, int lenght)
    {
        char* buffer = (char*)malloc(sizeof(char) * lenght);
        env->GetByteArrayRegion(textBuffer, 0, lenght, (jbyte *)buffer);
        
        std::string text;
        text.resize(lenght);
        for (int i=0; i<lenght; i++)
        {
            text[i] = buffer[i];
        }
        
        s_lock = true;
		CATextView* textView = s_map[(int)key];
        textView->setText(text);
        s_lock = false;
    }
	JNIEXPORT bool JNICALL Java_org_CrossApp_lib_CrossAppTextView_textChange(JNIEnv *env, jclass cls, jint key, jstring before, jstring change, int arg0, int arg1)
    {
        const char* charBefore = env->GetStringUTFChars(before, NULL);
        std::string strBefore = charBefore;
        env->ReleaseStringUTFChars(before, charBefore);
        const char* charChange = env->GetStringUTFChars(change, NULL);
        std::string strChange = charChange;
        env->ReleaseStringUTFChars(change, charChange);
        
		CATextView* textView = s_map[(int)key];
		if (textView->getDelegate())
		{
			return textView->getDelegate()->textViewShouldChangeCharacters(textView, arg0, arg1, strChange.c_str());
		}

		return true;
    }