Home Forums General XMetaL Discussion API call to pause UI updates Reply To: API call to pause UI updates


Reply to: API call to pause UI updates

Tony and Tom are both correct; FormattingUpdating was the property I was trying to remember.

As for Range vs Selection, I tend use Range whenever possible. In this case, I am inserting a sequence of elements (and elements within elements) and I wasn't sure I could do that with a range. In short, start with an empty range, add a tree of new elements to it, and then manifest it within the document.

This is a DITA use case. The user is inserting a strow or an sthead into a simpletable. The goal is to insert a strow or sthead that contains a number of stentry children (with child p element, as required by our DITA constraints) that is equal to the number of stentry elements in the first row-like element in the simpletable. The cursor should end up in the first p in the first stentry of the inserted strow or sthead.

The following is the element insertion logic that comes after I've analyzed the simpletable element and counted the stentry elements in the first strow or sthead. The elem variable is the name of the stentry or sthead being inserted. The entries variable is the number of entries found earlier.

    var firstp; //first p in first stentry; destination of cursor when done.
    var currentEntry; //current stentry being populated
    for (i = 1; i <= entries; i++) {
        currentEntry = Selection.ContainerNode;
        //Header cells get insertion text.
        if (elem == “sthead”) {
            Selection.InsertReplaceableText(“Enter new header”);
        if (i == 1) {
            firstp = Selection.ContainerNode;

These insertions is where the cursor moves around a bit. I can either wrap that logic in calls to Document.FormattingUpdating or if there's a more efficient alternative, let me know.

Best regards,

Paul Anderson
Compuware Corporation