// Create the textfield
var textField = new ccui.TextField("PlaceHolder","Marker Felt",30);
textField.x = widgetSize.width / 2.0;
textField.y = widgetSize.height / 2.0;
textField.addEventListener(this.textFieldEvent,this);
this._mainNode.addChild(textField);
return true;
}
return false;
},
textFieldEvent: function (textField,type) {
switch (type) {
case ccui.TextField.EVENT_ATTACH_WITH_IME:
var widgetSize = this._widget.getContentSize();
textField.runAction(cc.moveTo(0.225,
cc.p(widgetSize.width / 2,widgetSize.height / 2 + textField.height / 2)));
this._topDisplayLabel.setString("attach with IME");
break;
case ccui.TextField.EVENT_DETACH_WITH_IME:
var widgetSize = this._widget.getContentSize();
textField.runAction(cc.moveTo(0.175,cc.p(widgetSize.width / 2.0,widgetSize.height / 2.0)));
this._topDisplayLabel.setString("detach with IME");
break;
case ccui.TextField.EVENT_INSERT_TEXT:
this._topDisplayLabel.setString("insert words");
break;
case ccui.TextField.EVENT_DELETE_BACKWARD:
this._topDisplayLabel.setString("delete word");
break;
default:
break;
}
}
this._zhanghao = new cc.EditBox(cc.size(360.00,53.00),new cc.Scale9Sprite("DLinput.png"))
this._zhanghao.setName("zhaoguanghui");
this._zhanghao.setPosition(647,355);
this._zhanghao.setDelegate(this);
this._zhanghao.setMaxLength(20);
this._zhanghao.setPlaceHolder("点击输出账号");
this._zhanghao.setInputFlag(cc.EDITBox_INPUT_FLAG_SENSITIVE);//修改为不使用密文
this._zhanghao.setInputMode(cc.EDITBox_INPUT_MODE_ANY);
this.addChild(this._zhanghao,1,10);
return true;
},
editBoxEditingDidBegin: function (editBox) {
cc.log("editBox " + editBox.getName() + " DidBegin !");
},
editBoxEditingDidEnd: function (editBox) {
cc.log("editBox " + editBox.getName() + " DidEnd !");
},
editBoxTextChanged: function (editBox,text) {
cc.log("editBox " + editBox.getName() + ",TextChanged,text: " + text);
},
editBoxReturn: function (editBox) {
cc.log("editBox " + editBox.getName() + " was returned !");
}
原文链接:https://www.f2er.com/cocos2dx/343251.html