61 lines
1.5 KiB
JavaScript
61 lines
1.5 KiB
JavaScript
|
|
"use strict";
|
||
|
|
cc._RF.push(module, 'f95fdxLWdZBSo7OjC/kCxEt', 'pop.input.string.wnd');
|
||
|
|
// Scripts/mod/tips/popup/pop.input.string.wnd.js
|
||
|
|
|
||
|
|
"use strict";
|
||
|
|
|
||
|
|
/******************************************************************
|
||
|
|
*
|
||
|
|
* 字符串输入
|
||
|
|
*
|
||
|
|
******************************************************************/
|
||
|
|
|
||
|
|
var BridgeWindow = require("bridge.window");
|
||
|
|
var FxButton = require("nx.fx.button");
|
||
|
|
cc.Class({
|
||
|
|
"extends": BridgeWindow,
|
||
|
|
properties: {
|
||
|
|
nodTip: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.Node
|
||
|
|
},
|
||
|
|
edtInput: {
|
||
|
|
"default": null,
|
||
|
|
type: cc.EditBox
|
||
|
|
},
|
||
|
|
btnComfirm: {
|
||
|
|
"default": null,
|
||
|
|
type: FxButton
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 重载:参数打开
|
||
|
|
onOpenConfigs: function onOpenConfigs(_params) {
|
||
|
|
var tip = _params.tip || "tip";
|
||
|
|
nx.gui.setString(this.nodTip, "", nx.text.getKey(tip));
|
||
|
|
var str = _params.txt || "";
|
||
|
|
nx.gui.setString(this.edtInput, "", nx.text.getKey(str));
|
||
|
|
this.limit = _params.limit || [10, 20];
|
||
|
|
this.cb = _params.cb;
|
||
|
|
this.edtInput.maxLength = this.limit[1];
|
||
|
|
this.onEditChanged();
|
||
|
|
},
|
||
|
|
// 输入监听
|
||
|
|
onEditChanged: function onEditChanged() {
|
||
|
|
var len = 0;
|
||
|
|
var str = this.edtInput.string;
|
||
|
|
for (var i = 0; i < str.length; i++) {
|
||
|
|
len += str.charCodeAt(i) > 127 ? 2 : 1;
|
||
|
|
}
|
||
|
|
this.btnComfirm.lock(len < this.limit[0] || len > this.limit[1]);
|
||
|
|
},
|
||
|
|
// 确定
|
||
|
|
onConfirm: function onConfirm() {
|
||
|
|
var str = this.edtInput.string;
|
||
|
|
if (nx.dt.strEmpty(str)) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
nx.dt.fnInvoke(this.cb, this, str);
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
cc._RF.pop();
|