Skip to main content
Participating Frequently
January 18, 2010
Question

Blocking mouse interaction with a SelectionManager enabled TextFlow

  • January 18, 2010
  • 1 reply
  • 940 views

Hello, and thank you for taking the time to read my inquiry.

My goal is to display a text flow and highlight certain text spans programmatically without enabling mouse-based selection.

My original solution was to use a trivial subclass of the SelectionManager for my text flow's interaction manager, overriding the mouseUpHandler and mouseDownHandler functions to prevent the default behavior by calling event.preventDefault() and event.stopImmediatePropagation(), but this was unsuccessful.  The events passed to these handlers were not cancelable.

A secondary approach was to not use an interaction manager at all and instead change the background color for each target span element and then update the display with textFlow.flowComposer.updateAllControllers(), but this was far too computationally intensive.  Since the application will be changing the highlighted selection several times per second, a full refresh is untenably slow.

Is there some better way for me to continue to use the SelectionManager's high-speed updates while blocking mouse-based selection of my text?

This topic has been closed for replies.

1 reply

TLFanAuthor
Participating Frequently
January 19, 2010

So, the best intermediate solution I've found is to add a swath of MouseEvent listeners (CLICK, DOUBLE_CLICK, MOUSE_OVER, MOUSE_DOWN, MOUSE_UP) to the Sprite objects associated with my ContainerControllers.  These listeners just call event.preventDefault() and event.stopImmediatePropagation().

The end effect is what I desired -- no more user-initiated mouse-based selection of the text.

Still, this seems a bit awkward, especially if for some reason in the future I need mouse-based interaction with the host Sprites for reasons unrelated to the text flow.

Anyone know a more targeted or centralized solution out there?

Adobe Employee
January 20, 2010

How about setting the mouseChildren property of the host Sprites to false.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#mouseChildren

Richard

TLFanAuthor
Participating Frequently
January 21, 2010

Thanks, that was certainly a pointer in a more elegant direction.

Mouse-related selection interaction is effectively blocked when the host Sprite's mouseChildren and mouseEnabled properties are set to false.