Home Forums General XMetaL Discussion Join multiple changes into a single change/update event in XMetaL Author Reply To: Join multiple changes into a single change/update event in XMetaL Author

Derek Read

Reply to: Join multiple changes into a single change/update event in XMetaL Author

If your script is inside an MCR file contained within a single macro then all actions performed will be undone with one Undo action (ie: Ctrl+Z) by the user. Perhaps you have run into a similar issue to the one reported here: http://forums.XMetaL.com/index.php/topic,550.0.html

Your issue with flickering is typically caused by the use of the Selection object. We provide a similar object called Range which shares almost all the same properties and methods but has two major advantages:

1. There can only ever be one Selection object (it represents the user's 'real' selection), whereas you can have as many Range objects as you like.

2. The Selection object is always visible (ie: when you move it you are moving the user's 'real' selection) and it is always interacting with the document directly and visibly, whereas for the most part (except for specific properties and methods like Range.Select and when content is being inserted) Ranges are invisible.

If you feel you must use Selection, or where you do use Ranges but manipulations to the document are still rendered to the user during the running of your script (and you see flickering) you may work around this using the ActiveDocument.FormattingUpdating API to turn off updates to the document for a portion of a particular macro. Following example us from the Programmer's Guide:

ActiveDocument.FormattingUpdating = false;
// ... many operations requiring formatting updates
ActiveDocument.FormattingUpdating = true;

You must be careful that your script is always able to complete to the point where this API is set back to true within the same macro, otherwise, “formatting updating” will stay turned off for that document and unpredictable behavior may also occur. Basically what this means is that you cannot set this API to false in one macro and then turn it back on in a different macro or a subsequent run of the same macro, and if a macro terminates prematurely due to a runtime error you will have a similar problem (so test for possible causes of failure using “if” and / or “try…catch” or the equivalent in the scripting language you are using).

Yet another alternative is to build up a tree of DOM nodes (contained within one node) then insert that single node at the end of your script.

FYI: The 4.x releases of our products are no longer supported. We support the current release (6.0) and one full release back (5.0).

Reply

Products
Downloads
Support