SmileyTextField 组件使用

来源:互联网 发布:买车软件 编辑:程序博客网 时间:2024/05/16 15:22

多谢Luar的指点和分享这些代码,困扰的中文输入会影响表情定位的问题终于解决了。
在组件代码中updatePixelPos方法找到

1 : this.pixel_pos += this.CHAR_WIDTH_MAP[Math.min(1, this.is_bold)][string.charCodeAt(pos)];

替换成下面这段代码:
1 : //*************************************************************
2 : // Because all English Characters' width is stored in Array
3 : // If return undefined, it is Chinese character,
4 : // Hardcode Chinese character width = 13
5 : //*************************************************************
6 : var ccWIDTH = this.CHAR_WIDTH_MAP[Math.min(1, this.is_bold)][string.charCodeAt(pos)];
7 : ccWIDTH = (ccWIDTH == undefined) ? 13 : ccWIDTH;//这行就是解决问题的所在
8 : this.pixel_pos += ccWIDTH;

然后在parseHtmlShortcuts方法中找到
1 : test_pos += this.CHAR_WIDTH_MAP[Math.min(1, this.is_bold)][shortcut_str.charCodeAt(j)];

替换成下面代码:
//*************************************************************
// Because all English Characters' width is stored in Array
// If return undefined,  it is Chinese character,
// Hardcode Chinese character width = 13
//*************************************************************
var ccWIDTH = this.CHAR_WIDTH_MAP[Math.min(1, this.is_bold)][shortcut_str.charCodeAt(j)];
ccWIDTH = (ccWIDTH == undefined) ? 13 : ccWIDTH;
test_pos += ccWIDTH;
//

以上均引用luar的修改代码,非常感谢luar!
原创粉丝点击