Use the following code to add CCEditBox to the class as an input box. The Code is as follows:
// Add input default anchor (0.5, 0.5). modification is useless. Then, the coordinates cannot be layer-based // coordinates. The screen-based coordinates m_tf_input = CCEditBox must be used :: create (CCSizeMake (280*0.5, 60*0.5), CCScale9Sprite: create ("variables"); m_tf_input-> setFontColor (ccWHITE); m_tf_input-> setPlaceHolder (receivagemanager :: sharedreceivagemanager ()-> getLocalizedString ("Click here and input "). c_str (); m_tf_input-> setText (""); m_tf_input-> setMaxLength (MAX_CHAT_MSG_LENGTH); m_tf_input-> setReturnType (parameters); m_tf_input-> setDelegate (this ); this-> addChild (m_tf_input); m_tf_input-> setPosition (ccp (m_originPoint.x + this-> getPosition (). x + m_size.width * 0.5-130 * 0.5f, m_originPoint.y + this-> getPosition (). y + m_size.height * 0.5-184 * 0.5f ));
There is no problem with inputting on the IOS platform, but the input cannot be accepted on the Android platform. Later I found that setting the touch priority is OK.
CCEditBox is inherited from CCControlButton, and then
CCControlButton inherits from CCControl, and then
CCControl has a function.
M_tf_input-> setdefatoutouchpriority (-128.
Because its default priority is 1, the priority below Android is not enough.