views:

100

answers:

2

Hi

Is there any easy way to detect click outside of RichTextEditable? just like FlexMouseEvent.MOUSE_DOWN_OUTSIDE is used in popups.

Thanks

A: 

Hi,

I'm not sure if you mean the Spark RichEditableText component or the Halo RichTextEditor but they both dispatch the FlexMouseEvent.MOUSE_DOWN_OUTSIDE event.

If you have MXML you can listen for it like:

<mx:RichTextEditor id="myText" mouseDownOutside="mouseDownOutsideFunction(event)" />

or from ActionScript like:

myText.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE,mouseDownOutsideFunction);

Hope that helps.

Ryan
I tried this but it only works if RichEditableText is inside a popup "Dispatched from a component opened using the PopUpManager when the user clicks outside it"
Max
Ah I see. What is it you are trying to do? Maybe there is another way.
Ryan
+1  A: 

My approach to this would be to attach event listeners for MouseEvent.MOUSE_DOWN and SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE to the systemManager like so:

systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
systemManager.getSandboxRoot().addEventListener(SandboxMouseEvent.MOUSE_DOWN_SOMEWHERE, onMouseDown);

This way you get notified of any mouse down events and you can check to see if the event is happening inside of your RichEditableText component or not.

Hope that helps.

Wade Mueller
Thanks, ill try it.
Max