SmileyTextField 組件使用

多謝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!
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章