2 Replies Latest reply on Jan 23, 2011 9:53 PM by Gregory Lafrance

    selectRange does not work.

    Gregory Lafrance Level 6

      This code does not work and I have no idea why. Seems so simple, and nearly straight out of the

      help doc:

       

      <?xml version="1.0"?>
      <s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:s="library://ns.adobe.com/flex/spark">
        <s:layout>
          <s:VerticalLayout paddingLeft="10" paddingTop="10"/>
        </s:layout>
        <fx:Script>
          <![CDATA[
            private function selectTextRanges():void {
              ta.selectRange(23, 31);
              ti.selectRange(23, 32);
              ret.selectRange(23, 39);
            }
          ]]>
        </fx:Script>
        <s:TextArea id="ta"
                    selectionHighlighting="TextSelectionHighlighting.ALWAYS"
                    selectable="true"
                    text="Sample text in a Spark TextArea control."/>
        <s:TextInput id="ti" width="250"
                     selectionHighlighting="TextSelectionHighlighting.ALWAYS"
                     selectable="true"
                     text="Sample text in a Spark TextInput control."/>
        <s:RichEditableText id="ret"
                            selectionHighlighting="TextSelectionHighlighting.ALWAYS"
                            selectable="true"
                            text="Sample text in a Spark RichEditableText control."/>
        <s:Button click="selectTextRanges()" label="Select Text Ranges"/>
      </s:Application>
      
        • 1. Re: selectRange does not work.
          Gregory Lafrance Level 6

          Actually, it looks like the text is kind of selected, its sort of light gray highlighted, but when I select it using the mouse it is highlighted blue, and is obviously selected. Is the light gray highlighting what is supposed to happen when using selectRange()?

          • 2. Re: selectRange does not work.
            Gregory Lafrance Level 6

            Amazing but true, the light-gray background is controlled by the unfocusedTextSelectionColor style property, and the light-blue background is controlled by the focusedTextSelectionColor style property.

             

            Of course, the help doc does not seem to mention this, at least not in the section I was reading, so maybe I should be so hard on its writers, but mentioning this seems important.