And in *MyLayer::onEnter()*, i have set three CCTextFieldTTF as follow:
@
TextFieldTTF1 = CCTextFieldTTF::textFieldWithPlaceHolder(…);
TextFieldTTF2 = CCTextFieldTTF::textFieldWithPlaceHolder(…);
TextFieldTTF3 = CCTextFieldTTF::textFieldWithPlaceHolder(…);
@
I set as follow:
@
TextFieldTTF1~~>setDelegate;
TextFieldTTF2~~>setDelegate(this);
TextFieldTTF3->setDelegate(this);
@
but touch the TextfieldTTF, there’s no keyboard appear, and can’t insert the char into the textfield,
in the other way , when I don’t set Delegate to above three TextFieldTTFs(TextFieldTTF1,TextFieldTTF2,TextFieldTTF3), the keyboard is work well when touching the textfield ,and inserting chars from typing on keyboard into textfield…
Hi,jack Lin
I have modified TextInputTest.h and TextInputTest.cpp to meet your needs. Please download the attach files and replace them to have a try.
What I modified is ‘TextFieldTTFActionTest’ test demo. I have tested it on android and win32. And it works fine.
And I set delegate() in the MyLayer::onEnter*
<pre>
TextFieldTTF1 = CCTextFieldTTF::textFieldWithPlaceHolder;
TextFieldTTF2 = CCTextFieldTTF::textFieldWithPlaceHolder;
TextFieldTTF3 = CCTextFieldTTF::textFieldWithPlaceHolder;
TextFieldTTF1~~>setDelegate;
TextFieldTTF2~~>setDelegate;
TextFieldTTF3~~>setDelegate;
</pre>
It doesn’t work! there is no keyborad,and can’t insert words into textField!
But if I don’t setDelegate of these three TextFieldTTF , there is a keyboard and i can type into textfield, But in this way, it doesn’t run the virtual function MyLayer::onTextFieldInsertText to catch the words what i type on the keyboard.
<pre>
TextFieldTTF1 = CCTextFieldTTF::textFieldWithPlaceHolder;
TextFieldTTF2 = CCTextFieldTTF::textFieldWithPlaceHolder;
TextFieldTTF3 = CCTextFieldTTF::textFieldWithPlaceHolder;
//TextFieldTTF1~~>setDelegate;
//TextFieldTTF2~~>setDelegate;
//TextFieldTTF3~~>setDelegate;
</pre>
In the tests project, there is one layer to add another KeyboardNotificationLayer,
But in my pratice, I set the touch layer and KeyboardNotificationLayer in the same layer , if I don’t set delegate,keyboard can
appear and i can insert words into textfield,but can’t run the functionMyLayer::onTextFieldInsertText().
It doesn’t work when i set three textfieldsetDelegate()* ,
I don’t know why, i just wanna to capture the words what i type on the keyboard in the virtual function *onTextFieldInsertText()*, but i can’t do
class MyLayer : public KeyboardNotificationLayer,public CCTextFieldDelegate class TextFieldTTFActionTest : public KeyboardNotificationLayer, public CCTextFieldDelegate
?? what’s the difference? I don’t quite understand you.
I want to know the impletment of your MyLayer::ccTouchEnded.
void LoginLayer::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent)
{
CCPoint endPos = pTouch->locationInView(pTouch->view());
endPos = CCDirector::sharedDirector()->convertToGL(endPos);
float delta = 5.0f;
if (::abs(endPos.x - m_beginPos.x) > delta || ::abs(endPos.y - m_beginPos.y) > delta)
{
m_beginPos.x = m_beginPos.y = -1;
return;
}
CCRect rect;
CCPoint point = convertTouchToNodeSpaceAR(pTouch);
for( i = 0; i < 3; i++ )
{
rect = getRect(input[i]); // input[i] is the three (CCNode*) TextFieldTTF that i save while creating TextFieldTTF
Hit = CCRect::CCRectContainsPoint(rect, point);
if( Hit ) NowInputMaxChar = MaxCharInput[i];
onClickTrackNode( Hit, input[i] );
}
}
The difference is:
I only use only one layer named MyLayer to control touch, KeyboardNotificationLayer , and all of displays…
In the tests project, +it has two layers,a ContainerLayer layer ( TextInputTest ) adds a new layer( named TextFieldTTFActionTest+ that
derived from KeyboardNotificationLayer and CCLayer ) to control KeyboardNotificationLayer.
I don’t know what problem could let me failed.
Can you try the way that I use?
just create a scene and create one layer, on this layer has one textfield to insert
words.
PS. I try to debug that, and when I set textfield->delegate,in the function onClickTrackNode, CCIMEDelegate::attachWithIME return false;
but when I don’t set delegate, CCIMEDelegate::attachWithIME return true,
Is anything wrong???
My touchEnded is declare as follow:
[…]
> The difference is:
>
I only use only one layer named MyLayer to control touch, KeyboardNotificationLayer , and all of displays…
>
In the tests project, +it has two layers,a ContainerLayer layer ( TextInputTest ) adds a new layer( named TextFieldTTFActionTest+ that
>
derived from KeyboardNotificationLayer and CCLayer ) to control KeyboardNotificationLayer.
>
I don’t know what problem could let me failed.
>
Can you try the way that I use?
>
just create a scene and create one layer, on this layer has one textfield to insert
>
words.
>
PS. I try to debug that, and when I set textfield->delegate,in the function onClickTrackNode, CCIMEDelegate::attachWithIME return false;
>
but when I don’t set delegate, CCIMEDelegate::attachWithIME return true,
>
Is anything wrong???
Hi, could you please send the demo to me by email.Thanks.