Flex 4: Detect click outside of RichEditableText
Is there any easy way to detect click outside of RichTextEditable? just like FlexMouseEvent.MOUSE_DOWN_OUTSIDE is used in popups.
开发者_JS百科Thanks
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.
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.
Came across this after searching for a similar problem, realise it's rather old, but more for the benefit of others.
You can use the focusOut event on TextInput/RichEditableText. Any click outside of the TextInput/RichEditableText will trigger an event to be dispatched.
So:-
<s:RichEditableText id="textInput" focusOut="textInput_focusOutHandler(event)" />
精彩评论