3 Replies Latest reply on Jun 14, 2012 7:15 PM by Flex harUI

    Setting selection point on TextFlow when mouseChildren=false

    mmickelson Level 1

      I have text in a TextFlow. I want the user to see the text get a filter applied when they mouse over the text itself (TextFlowLines), not the bounding box of the entire region. When they are not over the text lines, the mouse events should trigger on the display objects under it.


      For example, if the asterisk was a graphic under the text, it should receive click events, etc. instead of the textFlow rectangular container bounding the text.


      Here is some text that

      wraps      *


      To do this, I tried creating a sprite that had rectangles in the shape of the TextFlowLines to use as the hitArea for the wrapper that holds the textFlow so the mouseOver event could trigger the filter. I found I also had to set mouseChildren=false on the wrapper to allow the click through. This all works great except when clicking on the text, the cursor isn't placed at the position clicked. I assume this is because the MOUSE_DOWN event gets ignored by the text since the mouseChildren is false. Setting mouseChildren to true in the mouseDownHandler doesn't help. Probably because it's already too late at that point.


      Is there any way to figure out where to place the text cursor using the interactionManager using the mouse coordinates? Is there another way to go about this that would be easier? I've been trying a lot of options to get this to work and haven't come up with anything.


      Flex 4.5.1

      TLF 2.0

        • 1. Re: Setting selection point on TextFlow when mouseChildren=false
          Flex harUI Adobe Employee

          I’m not quite sure what you are looking for.  If I have the letter O can I click in the middle of it and it goes through to what is underneath?

          • 2. Re: Setting selection point on TextFlow when mouseChildren=false
            mmickelson Level 1

            Here's two images that will help.



            The first image is what I'm starting with. It shows the selection area. If I try to click in the upper part of the pink splotch graphic that's behind the text when the text isn't selected, I can't and I get the I-beam cursor. The second image shows the hit area assigned to the text so only when it is clicked will it actually select the text. Otherwise, I get no I-beam when hovering over the top part of the slotch (or the hit area for that matter), and can select it, no problem. So, the second image is what I want EXCEPT that when I click on the hit area, the I-beam cursor does not show up in the text, ready to type under the mouse click. This is what happens in the first image and is what would most likely be expected by a user.


            So, I want to allow the user to click on the hit area and then see the I-beam under where they clicked, in the text, ready to type.


            [edit] It may help if I could know what level or part of the textFlow triggers the I-beam and selection. Maybe I could somehow assign the hit area to that??

            • 3. Re: Setting selection point on TextFlow when mouseChildren=false
              Flex harUI Adobe Employee

              You can try a mask.


              But there are scenarios where you are trying to get the default mouse logic in the player to work and only if nothing important happens you want an object below to become the target.  If that is what you want, you can re-dispatch the event against a different target by using getObjectsUnderPoint and some other logic.