Skip navigation
Currently Being Moderated

Setting selection point on TextFlow when mouseChildren=false

Jun 12, 2012 3:57 PM

Tags: #event-propagation #textflow #tlf

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

 
Replies
  • Currently Being Moderated
    Jun 12, 2012 10:22 PM   in reply to mmickelson

    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?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 14, 2012 7:15 PM   in reply to mmickelson

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points