2 Replies Latest reply on Feb 24, 2007 6:00 AM by Newsgroup_User

    Selection.getBeginIndex()?

    Level 7
      I'm not having any luck getting the indexes of a selected word within an
      input field.

      I put a listener on the Selection object like so:


      --
      Dave -
      Head Developer
      www.blurredistinction.com
      Adobe Community Expert
      http://www.adobe.com/communities/experts/


        • 1. Re: Selection.getBeginIndex()?
          Level 7
          I hate when I do that.

          I'm not having any luck getting the indexes of a selected word within an
          input field.

          I put a listener on the Selection object like so:

          var selListener:Object = new Object();
          selListener.onSetFocus = function(oldFocus, newFocus) {
          trace(newFocus);
          };
          Selection.addListener(selListener);

          newFocus traces properly (_level0.theBody) when I click in the field and
          select a word, so I know the focus is correct.

          So, on a button I have this:

          btnDelete.onRelease = function(){
          trace(Selection.getBeginIndex());
          }

          I always get -1, which means no field has the focus, according to Help.


          --
          Dave -
          Head Developer
          www.blurredistinction.com
          Adobe Community Expert
          http://www.adobe.com/communities/experts/


          • 2. Re: Selection.getBeginIndex()?
            Level 7
            OK, I did find clicking the button sets the focus of the Selection object to
            null. I guess that makes sense. So, I figured I can store newFocus in a
            variable and get the index based on the proper focus.

            So, I changed the onSetFocus handler to this:

            selListener.onSetFocus = function(oldFocus, newFocus) {
            if (newFocus != null) {
            thisRoot.focus = newFocus;
            }
            };

            Now I'm not sure it's possible to use the focus variable with
            Selection.getBeginIndex().

            Thoughts?



            --
            Dave -
            Head Developer
            www.blurredistinction.com
            Adobe Community Expert
            http://www.adobe.com/communities/experts/