注册

[寒江孤叶丶的CrossApp之旅_10][入门系列]CrossApp中CATextField的...

CrossApp中CATextField的使用

CATextField是CrossApp中用于接收用户输入的控件
auto textField = CATextField::createWithCenter(CADipRect(size.width*0.5, size.height*0.7, size.width*0.6, size.height*0.05));
textField->setBackgroundView(CAScale9ImageView::createWithImage(CAImage::create("source_material/ex1.png")));//设置背景图
textField->setPlaceHolder("Please enter some infomation");//设置默认文字
textField->setInputType(KEY_BOARD_INPUT_NORMAL);//设置输入方式
textField->setFontSize(_px(24));//设置字体大小
textField->setSpaceHolderColor(CAColor_yellow);
std::string str=textField->getText();//获取用户所输入的内容 默认打开的键盘类型有以下三种
enum eKeyBoardType
{
KEY_BOARD_TYPE_NORMAL = 0,
KEY_BOARD_TYPE_NUMBER,
KEY_BOARD_TYPE_ALPHABET,
}; KEY_BOARD_TYPE_NORMAL 默认形式

KEY_BOARD_TYPE_NUMBER 数字

KEY_BOARD_TYPE_ALPHABET 字母

CATextField的文本显示方式有以下两种:

enum eKeyBoardInputType
{
KEY_BOARD_INPUT_NORMAL = 1,
KEY_BOARD_INPUT_P**WORD,
}; KEY_BOARD_INPUT_NORMAL 一般输入模式

KEY_BOARD_INPUT_P**WORD 密码输入模式

目前0.3.5版本,CATextField在mac平台上有若**的bug,例如无法设置默认文字(运行崩溃),无法设置接收用户输入等等,但是在ios平台上这些功能都支持。还是等**完善吧~

已邀请:

要回复问题请先登录注册