aardio统计富文本编辑框中下划线标记的个数

admin2021-10-28  176

var getUnderlineCount = function(rtfEdit) {

    // 参数为 mainForm.richedit
    if (!rtfEdit) {
        return 0;
    }

    var maxLen = mainForm.richedit.getLength();
    var i = 1;
    var j = 1;
    var count = 0;

    while (i <= maxLen) {
        //console.log(i);
        mainForm.richedit.setsel(i, i);
        var charformat1 = mainForm.richedit.getSelCharformat();
        var gf1 = charformat1.getFont();
        if (gf1.underline > 0) {
            j = i   1;
            while (j <= maxLen) {
                mainForm.richedit.setsel(j, j);
                var charformat2 = mainForm.richedit.getSelCharformat();
                var gf2 = charformat2.getFont();
                if (gf2.underline > 0) {
                    j = j   1;
                } else {
                    break;
                }
            }
            //console.log(i, j - 1);
            //mainForm.richedit.setsel(i, j - 1);
            count = count   1;
            i = j;
            continue;
        }
        i = i   1;
    }
    return count;
}
转载请注明原文地址: http://www.aardio.net/read-249.html
最新回复(0)
aardio问答
aardio编程语言