2.4.6,随便创建一个场景丢进去一个editbox
然后输入1.2,按点的时候指标会跑到前面去,22.2也是,反正只要是再数字后面输入了小数点就会移动到首位去,然后再按一次才会出小数点
官方人员看一下
我吧cocos生成的html元素放在一个新创建的html标签里面是好的,但是在cocos里面这个标签输入小数点就是有问题的
input tabindex=“0” class=“cocosEditBox” id=“EditBoxId_2” type=“number” style=“border: 0px; background: transparent; width: 750px; height: 40px; outline: medium; padding: 0px; text-transform: none; position: absolute; bottom: 0px; left: 2px; transform: matrix(1, 0, 0, 1, 0, -505.853); transform-origin: 0px 100% 0px; font-size: 20px; color: rgb(255, 255, 255); font-family: Arial; text-align: left; display: none;” maxlength=“8” placeholder=“Enter text here…”
稍微改了下显示
input tabindex=“0” class=“cocosEditBox” id=“EditBoxId_2” type=“number” style=" background: transparent; width: 750px; height: 40px; outline: medium; padding: 0px; text-transform: none; position: absolute; bottom: 0px; left: 2px; transform: matrix(1, 0, 0, 1, 0, -505.853); transform-origin: 0px 100% 0px; font-size: 20px; color: rgb(0, 0, 0); font-family: Arial; text-align: left;" maxlength=“8” placeholder=“Enter text here…”
看了下,web输入1.小数点打印也是1.
这个处理想同就不调用editboxTextChanged
但是这个光标是怎么移动到首位的就不清楚了
numeric 表示整数
哦,那你在DECIMAL看看又是咋样?
我这边是网页哦
光标确实有问题,已告知相关人员,感谢反馈!
WebEditBoxImpl.js
// _updateInputType 函数修改如下代码:
_updateInputType () {
...
} else if(inputMode === InputMode.NUMERIC || inputMode === InputMode.DECIMAL) {
type = 'text';
} else if(inputMode === InputMode.PHONE_NUMBER) {
}
...
//onInput函数 插入如下代码
cbs.onInput = function () {
...
if (maxLength >= 0) {
elem.value = elem.value.slice(0, maxLength);
}
// begin
if(impl._inputMode === InputMode.NUMERIC || impl._inputMode === InputMode.DECIMAL) {
let f = function(str) {
let result = "";
let dotIdx = -1;
for (let index = 0; index < str.length; index++) {
const element = str[index];
//第一个字符可以是0,暂时这样
if (element >= '0' && element <= '9') {
result += element;
} else if (dotIdx == -1 && element == '.' && index > 0) {
//第一个字符不能是.
result += element;
dotIdx = index;
}
}
//保留2位小数
if(dotIdx != -1) {
result = result.substring(0, dotIdx + 3);
}
return result
};
elem.value=f(elem.value);
}
// end
impl._delegate.editBoxTextChanged(elem.value);
这样改无法满足需求:在手机上,弹出数字键盘
2.4.8还有这个问题
在numeric/decimal上无法直接顺畅的输入小数与负数,e o 等等
通过滚轮可以滚出负数
这个问题解决吗?想咨询一下
text-changed事件里面处理了下内容
踏马的。。。我就说为什么这玩意不得劲…
3.8依然存在!