views:

41

answers:

2

I have a text area on which I would like to listen to change events when I change the text formatting using setFormatOfRange(). So far all other events I have tried, such as Event.CHANGE or TextOperationEvent.CHANGE are only dispatched when the actual text is changed.

Anyone know what I should be listening for ?

+1  A: 

TextArea (or any other text controls for that matter) doesn't fire any events for changes in text formatting. Even the text change events are fired only when the text is changed manually by the user - not when you change it programmatically.

The TextOperationEvent class represents events that are dispatched when text content changes due to user operations such as inserting characters, backspacing, pasting, or changing text attributes.

Amarghosh
Thanks for the answer, but what would "text attribues" include ?
Tarek
If this helps, my goal is to store textFlow in XML format after each format or text change, any ideas?
Tarek
@Tarek you're changing them manually, right? you can update the xml everytime you do that..
Amarghosh
It's text editor so it is updated by user action. I call setformatofrange on various button clicks. In any event, I have resorted to a custom event since there is nothing built-in. Did you have something else in mind?
Tarek
Custom events are the way to go it seems.
Amarghosh
A: 

Actually you can get TextOperationEvent.CHANGE when formatting is change, but only if you use EditManager. You should create an EditManager object and assigns to TextArea.textFlow.interactionManager and all your format operation should be performed through this EditManager object. It has methods like applyFormat.

And I do not recommend using setFormatOfRange because it's pretty slow for large number of format operation. Instead you should use EditManager or ApplyFormatOperation objects. here's a post in which is explained how to use ApplyFormatOperation objects

tbgdn