cocos2d editBox 监听按钮

yuanhuan799 2018-06-09 05:20:33


上图,我点击“发送”按钮和点击其他地方都是调用下面两个函数。
editBoxEditingDidEnd();
editBoxReturn();

有没有什么区别,是我点击“发送”按钮的

cocos 3.6 xcode 下 ios
...全文
669 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuanhuan799 2018-06-11
  • 打赏
  • 举报
回复
自己搞定了。修改两个地方。 标记下 1.文件:UIEditBoxImpl-ios.mm

- (BOOL)textFieldShouldReturn:(UITextField *)sender
{
    if (sender == textField_) {
        [sender resignFirstResponder];
        

        cocos2d::ui::EditBoxDelegate* pDelegate = getEditBoxImplIOS()->getDelegate();
        if (pDelegate != NULL)
        {
            pDelegate->editBoxReturnButton(getEditBoxImplIOS()->getEditBox());
        }
    }
    return NO;
}
2.文件:UIEditBox.h

// class EditBoxDelegate 下面增加editBoxReturnButton
         /**
         * This method is called when the return button was pressed or the outside area of keyboard was touched.
         * @param editBox The edit box object that generated the event.
         * @param returnType One of the EditBox::KeyboardReturnType constants.
         */
        virtual void editBoxReturn(EditBox* editBox, int returnType) = 0;
        
        /**
         * This method is called when the return button was pressed
         * @param editBox The edit box object that generated the event.
         */
        virtual void editBoxReturnButton(EditBox* editBox){};
接下来就是自己继承实现

721

社区成员

发帖
与我相关
我的任务
社区描述
Cocos2d-x相关内容讨论专区
社区管理员
  • Cocos2d-x
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧