Repository: flex-tlf Updated Branches: refs/heads/develop 235cd97ee -> 913056000
Improved keyboard navigation in text surrounding tables Project: http://git-wip-us.apache.org/repos/asf/flex-tlf/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-tlf/commit/91305600 Tree: http://git-wip-us.apache.org/repos/asf/flex-tlf/tree/91305600 Diff: http://git-wip-us.apache.org/repos/asf/flex-tlf/diff/91305600 Branch: refs/heads/develop Commit: 91305600049ab941a339488e394fdfdbd5f4e50b Parents: 235cd97 Author: Harbs <[email protected]> Authored: Mon Dec 28 22:13:44 2015 +0200 Committer: Harbs <[email protected]> Committed: Mon Dec 28 22:13:44 2015 +0200 ---------------------------------------------------------------------- .../textLayout/elements/ParagraphElement.as | 17 ++++++++-- .../flashx/textLayout/utils/NavigationUtil.as | 33 +++++++++++++++----- 2 files changed, 40 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/91305600/textLayout/src/flashx/textLayout/elements/ParagraphElement.as ---------------------------------------------------------------------- diff --git a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as index 0622c84..dbb01b8 100644 --- a/textLayout/src/flashx/textLayout/elements/ParagraphElement.as +++ b/textLayout/src/flashx/textLayout/elements/ParagraphElement.as @@ -805,6 +805,9 @@ package flashx.textLayout.elements public function findPreviousAtomBoundary(relativePosition:int):int { var tb:TextBlock = getTextBlockAtPosition(relativePosition); + if(!tb || !tb.content) + return relativePosition-1; + var tbStart:int = getTextBlockStart(tb); var textBlockPos:int = relativePosition - tbStart; var tl:TextLine = tb.getTextLineAtCharIndex(textBlockPos); @@ -852,7 +855,11 @@ package flashx.textLayout.elements { tl = tl.previousLine; if (!tl) - return -1; + { + if(tb != _textBlocks[0]) + return relativePosition-1; + return -1; + } // need this when 0x2028 line separator in use if (tl.textBlockBeginIndex + tl.rawTextLength == textBlockPos) return tl.textBlockBeginIndex + tl.rawTextLength - 1 + tbStart; @@ -899,6 +906,8 @@ package flashx.textLayout.elements public function findNextAtomBoundary(relativePosition:int):int { var tb:TextBlock = getTextBlockAtPosition(relativePosition); + if(!tb || !tb.content) + return relativePosition+1; var tbStart:int = getTextBlockStart(tb); var textBlockPos:int = relativePosition - tbStart; var tl:TextLine = tb.getTextLineAtCharIndex(textBlockPos); @@ -941,7 +950,11 @@ package flashx.textLayout.elements { tl = tl.nextLine; if (!tl) - return -1; + { + if(tb != _textBlocks[_textBlocks.length-1]) + return relativePosition+1; + return -1; + } return tl.textBlockBeginIndex + tbStart; } while (++textBlockPos) http://git-wip-us.apache.org/repos/asf/flex-tlf/blob/91305600/textLayout/src/flashx/textLayout/utils/NavigationUtil.as ---------------------------------------------------------------------- diff --git a/textLayout/src/flashx/textLayout/utils/NavigationUtil.as b/textLayout/src/flashx/textLayout/utils/NavigationUtil.as index 091ceda..fea8549 100644 --- a/textLayout/src/flashx/textLayout/utils/NavigationUtil.as +++ b/textLayout/src/flashx/textLayout/utils/NavigationUtil.as @@ -25,6 +25,7 @@ package flashx.textLayout.utils import flashx.textLayout.compose.IFlowComposer; import flashx.textLayout.compose.TextFlowLine; + import flashx.textLayout.compose.TextFlowTableBlock; import flashx.textLayout.container.ContainerController; import flashx.textLayout.container.ScrollPolicy; import flashx.textLayout.elements.FlowLeafElement; @@ -337,6 +338,7 @@ package flashx.textLayout.utils { var endIdx:int; var targetTextLine:TextLine = targetFlowLine.getTextLine(true); + var blockOffset:int = targetFlowLine.paragraph.getTextBlockAbsoluteStart(targetTextLine.textBlock); var currentTextLine:TextLine = curTextFlowLine.getTextLine(true); var bidiRightToLeft:Boolean = ((currentTextLine.getAtomBidiLevel(atomIndex) % 2) != 0); @@ -412,7 +414,7 @@ package flashx.textLayout.utils paraSelectionIdx = leanRight ? targetTextLine.getAtomTextBlockEndIndex(atomIndex) : targetTextLine.getAtomTextBlockBeginIndex(atomIndex); } } - endIdx = targetFlowLine.paragraph.getAbsoluteStart() + paraSelectionIdx; + endIdx = blockOffset + paraSelectionIdx; } return endIdx; } @@ -447,8 +449,8 @@ package flashx.textLayout.utils var lineStart:int = curTextFlowLine.absoluteStart; var lineDelta:int = endIdx - lineStart; var currentTextLine:TextLine = curTextFlowLine.getTextLine(true); - var para:ParagraphElement = curTextFlowLine.paragraph; - var atomIndex:int = currentTextLine.getAtomIndexAtCharIndex(endIdx - para.getAbsoluteStart()); + var blockOffset:int = curTextFlowLine.paragraph.getTextBlockAbsoluteStart(currentTextLine.textBlock); + var atomIndex:int = currentTextLine.getAtomIndexAtCharIndex(endIdx - blockOffset); var bidiRightToLeft:Boolean = ((currentTextLine.getAtomBidiLevel(atomIndex) % 2) != 0); var curPosRect:Rectangle = currentTextLine.getAtomBounds(atomIndex); var currentTextLineX:Number = currentTextLine.x; @@ -483,8 +485,11 @@ package flashx.textLayout.utils //at this point, we have the global point of our current position. Now adjust x or y to the //baseline of the next line. - var nextFlowLine:TextFlowLine = textFlow.flowComposer.getLineAt(curLine + 1); - if (nextFlowLine.absoluteStart >= limitIdx) + var lineInc:int = 1; + var nextFlowLine:TextFlowLine = textFlow.flowComposer.getLineAt(curLine + lineInc); + while(nextFlowLine is TextFlowTableBlock) + nextFlowLine = textFlow.flowComposer.getLineAt(++lineInc + curLine); + if (!nextFlowLine || nextFlowLine.absoluteStart >= limitIdx) { if (!extendSelection) range.activePosition = range.anchorPosition = textFlow.textLength - 1; @@ -567,8 +572,8 @@ package flashx.textLayout.utils var lineStart:int = curTextFlowLine.absoluteStart; var lineDelta:int = endIdx - lineStart; var currentTextLine:TextLine = curTextFlowLine.getTextLine(true); - var para:ParagraphElement = curTextFlowLine.paragraph; - var atomIndex:int = currentTextLine.getAtomIndexAtCharIndex(endIdx - para.getAbsoluteStart()); + var blockOffset:int = curTextFlowLine.paragraph.getTextBlockAbsoluteStart(currentTextLine.textBlock); + var atomIndex:int = currentTextLine.getAtomIndexAtCharIndex(endIdx - blockOffset); var curPosRect:Rectangle = currentTextLine.getAtomBounds(atomIndex); var currentTextLineX:Number = currentTextLine.x; var curPosRectLeft:Number = curPosRect.left; @@ -602,7 +607,19 @@ package flashx.textLayout.utils //at this point, we have the global point of our current position. Now adjust x or y to the //baseline of the next line. - var prevFlowLine:TextFlowLine = textFlow.flowComposer.getLineAt(curLine - 1); + var lineInc:int = 1; + var prevFlowLine:TextFlowLine = textFlow.flowComposer.getLineAt(curLine - lineInc); + while(prevFlowLine is TextFlowTableBlock) + prevFlowLine = textFlow.flowComposer.getLineAt(curLine - (++lineInc)); + if (!prevFlowLine) + { + if (!extendSelection) + range.activePosition = range.anchorPosition = 0; + else + range.activePosition = 0; + return true; + } + // get the last container so that we can make sure the previous line is in view. var controller:ContainerController = textFlow.flowComposer.getControllerAt(textFlow.flowComposer.numControllers-1); var firstPosInContainer:int = controller.absoluteStart;
