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

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


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.



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.


class EbDelegate : public cocos2d::extension::EditBoxDelegate

      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;


Have a look at class reference too.