CCEditBOX - How To get Text.? Please Help...urgent

In my game I m making Chat Box,in which whatever user types in edit box is displayed somewhere else after he has done typing.but my problem is how to know when user has typed and getting the typed string.
if i use getText() function it always returns empty text……it might be getting text before the user types in.
How can we make it to get text after user types in the edit box.
Thanx

Hello

I think you should call setDelegate method for EditBox object. In class inherited from the EditBoxDelegate class you can overload functions like editBoxReturn which would be called when user ends up typing I believe.

Example:

class EbDelegate : public cocos2d::extension::EditBoxDelegate
{
public:

      virtual void editBoxEditingDidBegin( cocos2d::extension::EditBox* editBox )
      {
      }

      virtual void editBoxReturn( cocos2d::extension::EditBox* editBox )
      {
        const char *str = editBox->getText();
       // Do something useful
      }
};

...

EditBox *eb = EditBox::create();
EbDelegate dbd;

eb->setDelegate(&ebd);

Have a look at class reference too.

http://www.cocos2d-x.org/reference/native-cpp/V3.0alpha0/df/d16/classcocos2d_1_1extension_1_1_edit_box_delegate.html

1 Like