开发者

Finding previous word boundary with enter key?

This code works great and it get the last word, but when I use enter key it behaves erroneously and stops getting last word(s). When I comment the findPreviousWordBoundary line, it gets all text:

<fx:Script>
    <![CDATA[
        import flashx.textLayout.elements.ParagraphElement;
        protected function togglebutton1_clickHandler(event:MouseEvent):void {
            va开发者_如何学Gor urlLoader:URLLoader = new URLLoader();
            var suggestions:Array = new Array();
            var suggested:Array = new Array();
            var textfields:Array = new Array();
            var format:TextFormat = new TextFormat();
            var currentSelection:int = -1;
            mytextflow.addEventListener(KeyboardEvent.KEY_UP, suggest);

            function suggest(event:KeyboardEvent):void {
                suggested = [];
                var activePos:int = mytextflow.selectionActivePosition 
                var curParagraph:ParagraphElement = 
                    mytextflow.textFlow.findLeaf(activePos).getParagraph(); 
                var wordBoundary:int = curParagraph.
                    findPreviousWordBoundary(activePos);
                //var lastword:String = curParagraph.getText(wordBoundary,activePos);
            }               
        }
    ]]>
</fx:Script>

<s:ToggleButton  x="21" y="10" 
    click="togglebutton1_clickHandler(event)"/>
<s:RichEditableText 
    id="mytextflow" 
    x="111" 
    y="43" 
    width="363" 
    height="285" 
    backgroundColor="#C39191"/>             
</s:Application>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜