如何确定editor已经翻到文档结尾和文档开始
如何确定editor已经翻到文档结尾和文档开始
[解决办法]
则和要通过获取行来计算,这是我曾经在RichTextEditor中实现其模拟Label显示时的滚动效果。。希望可以有所帮助。。。
TTmLineInfo lineInfo; TTmPosInfo2 posInfo; TInt totalLineNumber = iAnsLabel->TextLayout()->GetLineNumber(iAnsLabel->RichText()->DocumentLength()); //获取当前光标在文本中的行数 TInt currentLineNumber; TTmDocPosSpec docPos(iAnsLabel->CursorPos(), TTmDocPosSpec::ELeftToRight); iAnsLabel->TextView()->FindDocPosL(docPos, posInfo, &lineInfo); currentLineNumber=lineInfo.iLineNumber; const TRect viewRect = iAnsLabel->TextView()->ViewRect(); // visiable rect //获取当前屏幕中最下面行在文本中的行数(brLineNumber)及右底端光标的坐标(brPos) TInt brLineNumber/*, brPos*/; iAnsLabel->TextLayout()->FindXyPos(viewRect.iBr, posInfo, &lineInfo); brLineNumber=lineInfo.iLineNumber;、 //获取当前屏幕中最上面行在文本中的行数(tlLineNumber)及左顶端光标的坐标(tlPos) TInt tlLineNumber/*, tlPos*/; iAnsLabel->TextLayout()->FindXyPos(viewRect.iTl, posInfo, &lineInfo); tlLineNumber=lineInfo.iLineNumber; //tlPos=posInfo.iDocPos.iPos; TInt viewRectLineNumber=brLineNumber-tlLineNumber; if (aKeyEvent.iCode == EKeyUpArrow) { if (currentLineNumber == brLineNumber) { //iAnsLabel->SetCursorPosL(tlPos, EFalse); for (TInt i=0; i<viewRectLineNumber; i++) iAnsLabel->MoveCursorL(TCursorPosition::EFLineUp, EFalse); } } if (aKeyEvent.iCode == EKeyDownArrow) { if (currentLineNumber == tlLineNumber) { //iAnsLabel->SetCursorPosL(brPos, EFalse); for (TInt i=0; i<viewRectLineNumber; i++) iAnsLabel->MoveCursorL(TCursorPosition::EFLineDown, EFalse); } //if(iAnsLabel->CursorPos() == iAnsLabel->RichText()->DocumentLength()) if (currentLineNumber == totalLineNumber) { this->SwitchFocus(); return EKeyWasConsumed; } } }
[解决办法]
TextLength和PosRangeInBand结合使用